package com.ygxsk.carhome.ui.evaluate;

import android.Manifest;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.KeyboardUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.NetworkUtils;
import com.blankj.utilcode.util.ObjectUtils;
import com.blankj.utilcode.util.StringUtils;
import com.flyco.roundview.RoundTextView;
import com.gyf.immersionbar.ImmersionBar;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.XXPermissions;
import com.hjq.toast.Toaster;
import com.kongzue.dialogx.dialogs.PopTip;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BasePopupView;
import com.trello.rxlifecycle4.android.ActivityEvent;
import com.yanzhenjie.permission.runtime.Permission;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.alertview.AlertView;
import com.ygxsk.carhome.alertview.OnItemClickListener;
import com.ygxsk.carhome.configeng.GifSizeFilter;
import com.ygxsk.carhome.configeng.Glide4Engine;
import com.ygxsk.carhome.constant.ConstantApi;
import com.ygxsk.carhome.constant.ConstantSign;
import com.ygxsk.carhome.constant.ExtraKey;
import com.ygxsk.carhome.constant.ExtraValue;
import com.ygxsk.carhome.enumwrap.EvaluteCarEstimateType;
import com.ygxsk.carhome.enumwrap.EvalutePriceType;
import com.ygxsk.carhome.enumwrap.SendType;
import com.ygxsk.carhome.event.EventCarEvaluateDetail;
import com.ygxsk.carhome.event.EventCarEvaluateMain;
import com.ygxsk.carhome.greendao.CarBrandLargeCategoryDaoManager;
import com.ygxsk.carhome.greendao.CarBrandSeriesLineDaoManager;
import com.ygxsk.carhome.listener.AuthorityCallbackListener;
import com.ygxsk.carhome.listener.DoSomeThingListener;
import com.ygxsk.carhome.listener.ErrorParentExtraSingle;
import com.ygxsk.carhome.listener.GainDataCallBackListener;
import com.ygxsk.carhome.listener.RxBus;
import com.ygxsk.carhome.response.CarBrandLargeCategory;
import com.ygxsk.carhome.response.CarBrandSeriesLineSmallCategory;
import com.ygxsk.carhome.response.EvaluateDetailItemBean;
import com.ygxsk.carhome.response.EvaluatePriceTypeInfo;
import com.ygxsk.carhome.response.EvaluateProblemInfo;
import com.ygxsk.carhome.response.EvaluateWadeDataInfo;
import com.ygxsk.carhome.response.EvaluateWadeInfo;
import com.ygxsk.carhome.response.EvaluteCurrentItemBean;
import com.ygxsk.carhome.retrofit.AddLogUpLoadInfo;
import com.ygxsk.carhome.retrofit.ApiException;
import com.ygxsk.carhome.retrofit.ApiRequestSubListener;
import com.ygxsk.carhome.retrofit.ApiService;
import com.ygxsk.carhome.retrofit.ErrorConsumer;
import com.ygxsk.carhome.retrofit.NetworkManager;
import com.ygxsk.carhome.retrofit.ResponseTransformer;
import com.ygxsk.carhome.rxbus.RxBusCalendarTime;
import com.ygxsk.carhome.rxbus.RxBusCarBrand;
import com.ygxsk.carhome.rxbus.RxBusCarProblem;
import com.ygxsk.carhome.rxbus.RxBusCarSeriesLineSmall;
import com.ygxsk.carhome.rxbus.RxBusCarWade;
import com.ygxsk.carhome.rxbus.RxBusCarWadeData;
import com.ygxsk.carhome.sys.PermissionInterceptor;
import com.ygxsk.carhome.sys.PermissionNameConvert;
import com.ygxsk.carhome.ui.ErrorActivity;
import com.ygxsk.carhome.ui.leads.LeadManagerGroupActivity;
import com.ygxsk.carhome.ui.leads.LeadsCarBrandLargeCategorySelectPopu;
import com.ygxsk.carhome.ui.leads.LeadsCarBrandSeriesLineSmalCategorySelectPopu;
import com.ygxsk.carhome.utils.CommTools;
import com.ygxsk.carhome.utils.CommUtils;
import com.ygxsk.carhome.utils.ViewUitls;
import com.ygxsk.carhome.views.ClearEditText;
import com.ygxsk.carhome.views.FJEditTextCountPublish;
import com.ygxsk.integrated.retrofit.Parameterkey;
import com.zhongjh.albumcamerarecorder.album.filter.BaseFilter;
import com.zhongjh.albumcamerarecorder.preview.BasePreviewActivity;
import com.zhongjh.albumcamerarecorder.settings.AlbumSetting;
import com.zhongjh.albumcamerarecorder.settings.CameraSetting;
import com.zhongjh.albumcamerarecorder.settings.GlobalSetting;
import com.zhongjh.albumcamerarecorder.settings.MultiMediaSetting;
import com.zhongjh.common.entity.LocalFile;
import com.zhongjh.common.entity.MultiMedia;
import com.zhongjh.common.entity.SaveStrategy;
import com.zhongjh.common.enums.MimeType;
import com.zhongjh.progresslibrary.entity.MultiMediaView;
import com.zhongjh.progresslibrary.listener.MaskProgressLayoutListener;
import com.zhongjh.progresslibrary.widget.MaskProgressLayout;

import org.greenrobot.eventbus.EventBus;

import java.io.File;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import cn.bingoogolapple.photopicker.widget.BGANinePhotoLayout;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.Consumer;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import pub.devrel.easypermissions.AfterPermissionGranted;
import pub.devrel.easypermissions.EasyPermissions;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023-07-15  09:15
 * @Description:车辆评估的添加评估页面；
 *
 */
public class CarEvaluateAddSubmitActivity extends ErrorActivity implements EasyPermissions.PermissionCallbacks, ErrorParentExtraSingle {


    //提交按钮-此处为【保存】能力
    @BindView(R.id.layoutbuttonevaluateaddsubmit)
    RoundTextView layoutButtonEvaluateAddSubmit;

    //有分发【分配客户】的能力
    @BindView(R.id.layoutbuttonevaluatedispatch)
    RoundTextView layoutButtonEvaluateDispatch;

    //客户的姓名需要添加的
    @BindView(R.id.editviewnamevaluate)
    ClearEditText editViewNameValuate;

    //客户的手机号 需要添加的
    @BindView(R.id.editviewphoneevaluate)
    ClearEditText editViewPhoneEvaluate;

    //车辆车型的外侧包裹
    @BindView(R.id.linelayoutcarmodel)
    RelativeLayout lineLayoutCarModel;

    //车辆车型
    @BindView(R.id.textviewpersoncarmodel)
    TextView textViewPersonCarModel;

    //看车地址 外侧包裹
    @BindView(R.id.linelayoutcarlookaddress)
    RelativeLayout lineLayoutCarLookAddress;
    //看车地址
    @BindView(R.id.textviewpersonlookcaraddress)
    TextView textViewPersonLookCarAddress;

    //上门时间的布局
    @BindView(R.id.linelayoutcarlooktime)
    RelativeLayout lineLayoutCarLookTime;
    //上门时间的具体值内容
    @BindView(R.id.textviewpersonlookcartime)
    TextView textViewPersonLookCarTime;

    //车辆的在线评估是有九宫格的
    @BindView(R.id.linelayoutcarevaluateonline)
    LinearLayout lineLayoutCarEvaluateOnLine;

    //车辆的在线评估是有九宫格的，如果不是在线评估进来的要隐藏
    @BindView(R.id.npl_item_moment_photos)
    BGANinePhotoLayout npl_item_moment_photos;

    //自然到店的 电话号码信息
//    @BindView(R.id.editviewphoneemployee)
//    ClearEditText editViewPhoneEmployee;

    //到店评估的中间表单

    //车牌的选择
    @BindView(R.id.layoutleadbrandevaluate)
    LinearLayout layoutLeadBrandEvaluate;

    //车辆品牌
    @BindView(R.id.textviewbrandevaluate)
    TextView textViewBrandEvaluate;

    //选择车系
    @BindView(R.id.layoutevaluatebrandline)
    LinearLayout layoutEvaluateBrandLine;
    //车系的文字填充
    @BindView(R.id.textviewevaluatebrandline)
    TextView textViewEvaluateBrandLine;
    //车型是手动输入的
    @BindView(R.id.editviewinputevaluatecarmodel)
    ClearEditText editViewInputEvaluateCarModel;

    //选择车辆的出厂时间 时间包裹
    @BindView(R.id.linearlayoutchooseoutlinetime)
    RelativeLayout linearLayoutChooseOutLineTime;

    //车辆的出厂时间包裹
    @BindView(R.id.textviewstarttimeoutline)
    TextView textViewStartTimeOutLine;

    //车辆的公里数 外侧包裹
//    @BindView(R.id.layoutinputcarmileoutside)
//    RelativeLayout layoutInputCarMileOutSide;

    //车辆的公里数文本填充
    @BindView(R.id.editviewcarmileoutside)
    ClearEditText editViewCarMileOutSide;

    //车辆的颜色 手动输入
    @BindView(R.id.editviewcarinputcolor)
    ClearEditText editViewCarInputColor;

    //车辆的事故 选择外侧包裹
    @BindView(R.id.layoutcarincidentoutside)
    LinearLayout layoutCarInCidentOutSide;
    //车辆的事故选择 文本填充
    @BindView(R.id.textviewcarincidentoutside)
    TextView textViewCarInCidentOutSide;

    //车辆的是否涉水外侧包裹
    @BindView(R.id.layoutcarinwadeoutside)
    LinearLayout layoutCarInWadeOutSide;
    //车辆的是否涉水的文本填充
    @BindView(R.id.textviewcarinwadeoutside)
    TextView textViewCarInWadeOutSide;

    //车辆评估的备注填充
    @BindView(R.id.editviewcontentevaluateremark)
    FJEditTextCountPublish editViewContentEvaluateRemark;

    @BindView(R.id.mplimagelistinevaluate)
    MaskProgressLayout mplimageListInEvaluate;

    //提交页面底部的一个帮助布局
    @BindView(R.id.textviewhelpinevaluatesubmitbottom)
    TextView textViewHelpiInEvaluateSubmitBottom;

    //报价类型  外侧包裹
    @BindView(R.id.layoutevaluatepircetype)
    LinearLayout layoutEvaluatePirceType;

    //价格的 类型 是一口价还是区间价
    @BindView(R.id.textviewpriceforevaluate)
    TextView textViewPriceForEvaluate;

    //单个的价格评估外侧包裹
    @BindView(R.id.linearlayoutsingleprice)
    RelativeLayout linearLayoutSinglePrice;

    //输入价格的文本信息--是一口价的单独一个价格
    @BindView(R.id.editviewevaluateprice)
    ClearEditText editViewEvaluatePrice;

    //最低价和最高价的外侧包裹
    @BindView(R.id.linearlayoutminandrmaxprice)
    LinearLayout linearLayoutMinAndMaxpPrice;
    //最低价
    @BindView(R.id.editviewevaluateminprice)
    ClearEditText editViewEvaluateMinPrice;
    //最高价
    @BindView(R.id.editviewevaluatemaxprice)
    ClearEditText editViewEvaluateMaxPrice;

    //输入车辆评估的底部备注信息
    @BindView(R.id.editviewevaluatebottomremark)
    FJEditTextCountPublish editViewEvaluateBottomRemark;

    //做图片上传的操作
    private static final int PRC_PHOTO_PICKER = 1;
    //页面的选择图片操作
    protected static final int REQUEST_CODE_CHOOSE = 2361;


    //一个临时的添加车辆 品牌列表
    private ArrayList<CarBrandLargeCategory> mDataResources_carBrandLarge = new ArrayList<>();
    //一个临时的车系内容
    private ArrayList<CarBrandSeriesLineSmallCategory> mDataResources_carBrandSeriesList = new ArrayList<>();

    //准备需要上传的信息
    //评估车辆这个人的姓名
    private String customerName_upLoad = "";
    //评估车辆那个人的手机号
    private String customerPhone_upLoad = "";

    //被评估车辆的品牌
    private String brandId_upLoad = "";
    //被评估车辆的-车系
    private String seriesId_upLoad = "";
    //品牌-车系-车型输入
    private String carName_upLoad = "";
    //车辆出厂日期
    private String releaseDate_upLoad = "";
    //车辆公里数 里程
    private String mileage_upLoad = "";
    //车辆颜色
    private String carColor_upLoad = "";
    //车辆事故id,非文本的填充
    private String accident_upLoad = "";
    //车辆涉水的id，非文本的填充
    private String wade_upLoad = "";
    //已经携带的图片集合？
//    private ArrayList<String> receptionImg_upLoad = new ArrayList<>();
    //这是做比对的字符串
    private String receptionImg_upLoad = "";
    //评估的附件，是图片列表
    private ArrayList<String> files_upLoad = new ArrayList<>();
    //中间填充文本的备注
    private String remark_upLoad = "";

    //价格类型：1一口价;2区间价;
    private String priceType_upLoad = "";
    //最低价，如果一口价，应该是两个价格
    private String minPrice_upLoad = "";
    //最高价
    private String maxPrice_upLoad = "";
    //评估备注
    private String priceRemark_upLoad = "";

    //上门评估--上门时间的上传
//    private String doorTime_upLoad;
    //上门评估--上门地址的上传
//    private String address_upLoad;

    //该页面的编辑的图片的hashMap,这里仅仅是上传用的，还有一个独立的只用来更新用的，
    private ArrayList<HashMap<String, Object>> fileSingleUpLoadFiles_upLoad_hashMap = new ArrayList<>();
    //用户接收到图片的 全路径，为了和后台做比对用的；
    private ArrayList<HashMap<String, Object>> fileSingleUpLoadFiles_modify_hashMap = new ArrayList<>();

    //添加跟进状态的适配器
//    private ArrayList<LeadsFollowUpInfoBean> mDataResources_followUp = new ArrayList<>();
    //添加车辆事故的数据
    private ArrayList<EvaluateProblemInfo> mDataResources_problem = new ArrayList<>();
    //车辆涉水的列表预备数据
    private ArrayList<EvaluateWadeDataInfo> mDataResources_wade = new ArrayList<>();

    //车辆的价格评估的类型  一口价或者区间价
    private ArrayList<EvaluatePriceTypeInfo> mDataResources_priceType = new ArrayList<>();

    //车辆品牌--弹窗；
    private BasePopupView basePopupView_carBrandLargeCategory;
    //选择车系的弹窗
    private BasePopupView basePopupView_carBrandSeriesSmallCategory;

    //日历的控件主要是出厂日期
    private BasePopupView basePopupView_manufacture_time;
    //车辆的事故弹窗
    private BasePopupView basePopupView_carProblem;
    //车辆涉水
    private BasePopupView basePopupView_carWade;
    //车辆的价格类型
    private BasePopupView basePopupView_carPriceType;

    //添加相机的设置
    private GlobalSetting mGlobalSetting;

    private int alreadyImageCount;
    private int alreadyVideoCount;
    private int alreadyAudioCount;

    //是哪种类型:主要是 【评估类型】
    private String flag_jumpfrom_where_type = "";

    //标志是【编辑】
    private boolean extra_evaluate_detail_is_edit = false;

    //携带这个条目的数据内容
    private EvaluteCurrentItemBean extra_evalute_current_item_bean;

    //从【评估详情】-携带的 评估详情信息，主要是为了 取出几个id;
    private EvaluateDetailItemBean extra_evalute_current_evaluate_detail_item_bean_outside;

    private BGANinePhotoLayout mCurrentClickNpl;

    //该页面仅仅只有预览的能力
    private static final int PRC_PHOTO_PREVIEW = 1;


    @OnClick({R.id.layoutbuttonevaluateaddsubmit, //保存按钮
            R.id.layoutbuttonevaluatedispatch,//分发能力分发人员列表
            R.id.layoutleadbrandevaluate, //车辆-品牌
            R.id.layoutevaluatebrandline,//车系
            R.id.linearlayoutchooseoutlinetime,//出厂日期
            R.id.layoutcarincidentoutside,//车辆事故的弹窗
            R.id.layoutcarinwadeoutside,//车辆涉水
            R.id.layoutevaluatepircetype//车辆价格的评估
    })//
    public void onViewClickInEvaluate(View v) {

        switch (v.getId()) {

            case R.id.layoutbuttonevaluatedispatch: {

                KeyboardUtils.hideSoftInput(mActivityInstance);
                //method_personDispatch_upLoad();
                Bundle extra_bundle = new Bundle();

                //String shopId = assetInSideBean.getShopId();
//                    //是 从潜客的详情  分配销售  进来的
                extra_bundle.putInt(ExtraKey.EXTRA_JUMPFROM_WHERE, ExtraValue.VALUE_JUMP_FORM_EVALUATE_DETAIL_ACTIVITY);
                //携带是新车，还是二手车，
                extra_bundle.putParcelable(ExtraKey.EXTRA_EVALUTE_CURRENT_ITEM_BEAN, extra_evalute_current_item_bean);

                ActivityUtils.startActivity(extra_bundle, LeadManagerGroupActivity.class);

                break;
            }

            case R.id.layoutbuttonevaluateaddsubmit: {//【提交】按钮；

                KeyboardUtils.hideSoftInput(mActivityInstance);

                //姓名信息
                customerName_upLoad = editViewNameValuate.getText().toString().trim();
                //手机号信息
                customerPhone_upLoad = editViewPhoneEvaluate.getText().toString().trim();
                //喜好的车型，该车车辆的车型
                carName_upLoad = editViewInputEvaluateCarModel.getText().toString().trim();
                //公里数
                mileage_upLoad = editViewCarMileOutSide.getText().toString();
                //车辆颜色
                carColor_upLoad = editViewCarInputColor.getText().toString();
                //备注信息
                remark_upLoad = editViewContentEvaluateRemark.getText().toString().trim();

                //评估的价格：一口价和区间价
                if (priceType_upLoad == EvalutePriceType.PRICETYPE_ONE_SINGLE.getIndex()) {
                    minPrice_upLoad = editViewEvaluatePrice.getText().toString().trim();
                    maxPrice_upLoad = editViewEvaluatePrice.getText().toString().trim();
                } else if (priceType_upLoad == EvalutePriceType.PRICETYPE_TWO_RANGE.getIndex()) {
                    minPrice_upLoad = editViewEvaluateMinPrice.getText().toString().trim();
                    maxPrice_upLoad = editViewEvaluateMaxPrice.getText().toString().trim();
                }

                //评估的备注信息
                priceRemark_upLoad = editViewEvaluateBottomRemark.getText().toString().trim();

                //一些必填内容校验
                //姓名必填
                if (TextUtils.isEmpty(customerPhone_upLoad)) {
                    CommUtils.checkDialog(mAlertView);
                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.customername_upload), true);
                    mAlertView.show();
                    return;
                }

                //手机号校验
                if (TextUtils.isEmpty(customerName_upLoad)) {
                    CommUtils.checkDialog(mAlertView);
                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.customerPhone_upLoad), true);
                    mAlertView.show();
                    return;
                }

                //请填写车辆品牌
                if (TextUtils.isEmpty(brandId_upLoad) || TextUtils.isEmpty(textViewBrandEvaluate.getText().toString().trim())) {
                    CommUtils.checkDialog(mAlertView);
                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.brandid_upload), true);
                    mAlertView.show();
                    return;
                }

                //请填写车辆品牌-的车系
                if (TextUtils.isEmpty(seriesId_upLoad) || TextUtils.isEmpty(textViewEvaluateBrandLine.getText().toString().trim())) {
                    CommUtils.checkDialog(mAlertView);
                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.seriesid_upload), true);
                    mAlertView.show();
                    return;
                }

                //请填写车辆品牌-的车型
                if (TextUtils.isEmpty(carName_upLoad)) {
                    CommUtils.checkDialog(mAlertView);
                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.carname_upload), true);
                    mAlertView.show();
                    return;
                }

                //出厂日期也是必填
                if (TextUtils.isEmpty(releaseDate_upLoad)) {
                    CommUtils.checkDialog(mAlertView);
                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.releasedate_upload), true);
                    mAlertView.show();
                    return;
                }

                //公里数不是必填 ？2024年1月19日16:33:31 我和苹果端确认，都不是必填项

                //请选择报价类型--第一次可以不是必填，也就是第二次评估时候 可以算评估：并且添加了评估价格，才算评估完毕。
//                if (TextUtils.isEmpty(priceType_upLoad)) {
//                    CommUtils.checkDialog(mAlertView);
//                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.pricetype_upload), true);
//                    mAlertView.show();
//                    return;
//                }

                //价格校验
//                if (TextUtils.isEmpty(minPrice_upLoad) || TextUtils.isEmpty(maxPrice_upLoad)) {
//                    CommUtils.checkDialog(mAlertView);
//                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.price_upload), true);
//                    mAlertView.show();
//                    return;
//                }

                //只有一个单个点击
                CommUtils.checkDialog(mAlertView);
                mAlertView = new AlertView(StringUtils.getString(R.string.clearaddorsubmitsuretitletips), //提示
                        StringUtils.getString(R.string.clearaddorsubmitsuremessage),//提示内容
                        StringUtils.getString(R.string.clearcachecancel), //取消
                        new String[]{StringUtils.getString(R.string.clearaddorsubmitsure)},//确定
                        null, mActivityInstance, AlertView.Style.Alert, new OnItemClickListener() {//
                    @Override
                    public void onItemClick(Object o, int position) {

                        if (position != AlertView.CANCELPOSITION) {

                            //根据不同跳转值判断 是哪种评估类型：
                            if (TextUtils.equals(flag_jumpfrom_where_type, EvaluteCarEstimateType.ESTIMATE_TYPE_NEW_ADD_ONE.getIndex())) {

                                //全新添加一个评估
                                method_gainAddSubmitInfo_upLoad_ESTIMATE_TYPE_ONSTORE();

                            } else if (TextUtils.equals(flag_jumpfrom_where_type, EvaluteCarEstimateType.ESTIMATE_TYPE_ONSTORE.getIndex())) {

                                //到店评估，需要获取详情，
                                if (extra_evaluate_detail_is_edit) {
                                    method_gainAddSubmitInfo_upLoad_updateEstimate();
                                } else {
                                    method_gainAddSubmitInfo_upLoad_ESTIMATE_TYPE_ONSTORE();
                                }

                            } else if (TextUtils.equals(flag_jumpfrom_where_type, EvaluteCarEstimateType.ESTIMATE_TYPE_ONDOOR.getIndex())) {

                                //上门评估
                                method_gainAddSubmitInfo_upLoad_updateEstimate();


                            } else if (TextUtils.equals(flag_jumpfrom_where_type, EvaluteCarEstimateType.ESTIMATE_TYPE_ONLINE.getIndex())) {

                                //在线评估
                                method_gainAddSubmitInfo_upLoad_updateEstimate();


                            } else if (TextUtils.equals(flag_jumpfrom_where_type, EvaluteCarEstimateType.ESTIMATE_TYPE_BOOKING.getIndex())) {

                                //预约评估
                                method_gainAddSubmitInfo_upLoad_updateEstimate();

                            }


                        }
                    }
                });

                mAlertView.setCancelable(true);
                mAlertView.show();

                break;
            }

            case R.id.layoutleadbrandevaluate: {//车辆品牌

                //在它之前有没有必选的
                KeyboardUtils.hideSoftInput(mActivityInstance);

                LeadsCarBrandLargeCategorySelectPopu leadsCarBrandLargeCategorySelectPopu = new LeadsCarBrandLargeCategorySelectPopu(CarEvaluateAddSubmitActivity.this,//
                        ExtraValue.MODIFY_LEAD_CARBRAND_SELECT,//
                        mDataResources_carBrandLarge);

                leadsCarBrandLargeCategorySelectPopu.setTitleName(getResources().getString(R.string.add_submit_add_model_out));

                if (mDataResources_carBrandLarge != null && !mDataResources_carBrandLarge.isEmpty()) {

                    //直接弹窗：
                    basePopupView_carBrandLargeCategory = new XPopup.Builder(CarEvaluateAddSubmitActivity.this)
                            .hasShadowBg(true)
                            .moveUpToKeyboard(false) //如果不加这个，评论弹窗会移动到软键盘上面;
                            .isViewMode(true)
                            .asCustom(leadsCarBrandLargeCategorySelectPopu)//
                            .show();

                } else {
                    //重新获取一遍接口；

                    gainCarBrandLargeCategory(new GainDataCallBackListener() {
                        @Override
                        public void doSomeThing() {

                            //直接弹窗：
                            basePopupView_carBrandLargeCategory = new XPopup.Builder(CarEvaluateAddSubmitActivity.this)
                                    .hasShadowBg(true)
                                    .moveUpToKeyboard(false) //如果不加这个，评论弹窗会移动到软键盘上面;
                                    .isViewMode(true)
                                    .asCustom(leadsCarBrandLargeCategorySelectPopu)//
                                    .show();

                        }
                    });

                }

                break;
            }

            case R.id.layoutevaluatebrandline: {//车辆品牌-车系

                KeyboardUtils.hideSoftInput(mActivityInstance);

                //如果车辆品牌是空，那么必须弹窗提示先选择车辆品牌
                if (TextUtils.isEmpty(brandId_upLoad) || TextUtils.isEmpty(textViewBrandEvaluate.getText().toString().trim())) {
                    CommUtils.checkDialog(mAlertView);
                    mAlertView = CommUtils.method_showAlertViewSingleSlowly(mActivityInstance, ConstantSign.ALERT_TITLE, getString(R.string.brandid_upload), true);
                    mAlertView.show();
                    return;
                }

                LeadsCarBrandSeriesLineSmalCategorySelectPopu leadsCarBrandSeriesLineSmalCategorySelectPopu = new LeadsCarBrandSeriesLineSmalCategorySelectPopu(CarEvaluateAddSubmitActivity.this,//
                        ExtraValue.MODIFY_LEAD_CARBRAND_SERIES_SELECT,//
                        mDataResources_carBrandSeriesList);

                leadsCarBrandSeriesLineSmalCategorySelectPopu.setTitleName(getResources().getString(R.string.car_choose_car_line));

                //必选车辆品牌之下的车系；
                if (mDataResources_carBrandSeriesList != null && !mDataResources_carBrandSeriesList.isEmpty()) {

                    //直接弹窗：
                    basePopupView_carBrandSeriesSmallCategory = new XPopup.Builder(CarEvaluateAddSubmitActivity.this)
                            .hasShadowBg(true)
                            .moveUpToKeyboard(false) //如果不加这个，评论弹窗会移动到软键盘上面;
                            .isViewMode(true)
                            .asCustom(leadsCarBrandSeriesLineSmalCategorySelectPopu)//
                            .show();

                } else {
                    //重新获取一遍接口；

                    gainCarBrandSeriesLineSmallCategory(brandId_upLoad, new GainDataCallBackListener() {
                        @Override
                        public void doSomeThing() {

                            //直接弹窗：
                            basePopupView_carBrandSeriesSmallCategory = new XPopup.Builder(CarEvaluateAddSubmitActivity.this)
                                    .hasShadowBg(true)
                                    .moveUpToKeyboard(false) //如果不加这个，评论弹窗会移动到软键盘上面;
                                    .isViewMode(true)
                                    .asCustom(leadsCarBrandSeriesLineSmalCategorySelectPopu)//
                                    .show();

                        }
                    }, true);

                }

                break;
            }

            case R.id.linearlayoutchooseoutlinetime: {//出厂日期

                KeyboardUtils.hideSoftInput(mActivityInstance);

                CalendarViewCustomPopup calendarViewCustomPopup = new CalendarViewCustomPopup(ExtraValue.RXBUS_EVALUATE_CAR_MANUFACTURE_TO_ADDSUBMIT, CarEvaluateAddSubmitActivity.this);

                //直接弹窗选择时间的
                basePopupView_manufacture_time = new XPopup.Builder(CarEvaluateAddSubmitActivity.this)
                        .hasShadowBg(true)
                        .moveUpToKeyboard(false)
                        .isViewMode(true)
                        .isDestroyOnDismiss(true) //对于只使用一次的弹窗，推荐设置这个
                        .isThreeDrag(false)
                        .asCustom(calendarViewCustomPopup)//
                        .show();


                break;
            }

            case R.id.layoutcarincidentoutside: {//车辆事故的选择弹窗

                KeyboardUtils.hideSoftInput(mActivityInstance);

                if (mDataResources_problem != null && !mDataResources_problem.isEmpty()) {

                    EvaluateProblemPopu evaluateProblemPopu = new EvaluateProblemPopu(CarEvaluateAddSubmitActivity.this,//
                            ExtraValue.MODIFY_EVALUATE_CAR_PROBLEM_SELECT,//
                            mDataResources_problem);

                    evaluateProblemPopu.setTitleName(getResources().getString(R.string.choose_car_problem));

                    basePopupView_carProblem = new XPopup.Builder(CarEvaluateAddSubmitActivity.this)
                            .hasShadowBg(true)
                            //.moveUpToKeyboard(false) //如果不加这个，评论弹窗会移动到软键盘上面;
                            .isViewMode(true)
                            //.autoDismiss(false)
                            //.isDestroyOnDismiss(true) //对于只使用一次的弹窗，推荐设置这个
                            //.isThreeDrag(false) //是否开启三阶拖拽，如果设置enableDrag(false)则无效
                            //.dismissOnTouchOutside(true)
                            //.notDismissWhenTouchInView()
                            .asCustom(evaluateProblemPopu)//
                            .show();

                } else {

                    getListByType_problem_accident(new GainDataCallBackListener() {
                        @Override
                        public void doSomeThing() {

                            EvaluateProblemPopu evaluateProblemPopu = new EvaluateProblemPopu(CarEvaluateAddSubmitActivity.this,//
                                    ExtraValue.MODIFY_EVALUATE_CAR_PROBLEM_SELECT,//
                                    mDataResources_problem);

                            evaluateProblemPopu.setTitleName(getResources().getString(R.string.choose_car_problem));

                            basePopupView_carProblem = new XPopup.Builder(CarEvaluateAddSubmitActivity.this)
                                    .hasShadowBg(true)
                                    //.moveUpToKeyboard(false) //如果不加这个，评论弹窗会移动到软键盘上面;
                                    .isViewMode(true)
                                    //.autoDismiss(false)
                                    //.isDestroyOnDismiss(true) //对于只使用一次的弹窗，推荐设置这个
                                    //.isThreeDrag(false) //是否开启三阶拖拽，如果设置enableDrag(false)则无效
                                    //.dismissOnTouchOutside(true)
                                    //.notDismissWhenTouchInView()
                                    .asCustom(evaluateProblemPopu)//
                                    .show();

                        }
                    });

                }

                break;
            }

            case R.id.layoutcarinwadeoutside: {//车辆涉水的弹窗

                KeyboardUtils.hideSoftInput(mActivityInstance);

                if (mDataResources_wade != null && !mDataResources_wade.isEmpty()) {

                    EvaluateWadeDataPopu evaluateWadeDataPopu = new EvaluateWadeDataPopu(CarEvaluateAddSubmitActivity.this,//
                            ExtraValue.MODIFY_EVALUATE_CAR_WADE_SELECT,//
                            mDataResources_wade);

                    evaluateWadeDataPopu.setTitleName(getResources().getString(R.string.choose_car_wade));

                    //直接弹窗：
                    basePopupView_carWade = new XPopup.Builder(CarEvaluateAddSubmitActivity.this)
                            .hasShadowBg(true)
                            //.moveUpToKeyboard(false) //如果不加这个，评论弹窗会移动到软键盘上面;
                            .isViewMode(true)
                            //.autoDismiss(false)
                            //.isDestroyOnDismiss(true) //对于只使用一次的弹窗，推荐设置这个
                            //.isThreeDrag(false) //是否开启三阶拖拽，如果设置enableDrag(false)则无效
                            //.dismissOnTouchOutside(true)
                            //.notDismissWhenTouchInView()
                            .asCustom(evaluateWadeDataPopu)//
                            .show();

                } else {

                    getListByType_wade(new GainDataCallBackListener() {
                        @Override
                        public void doSomeThing() {

                            EvaluateWadeDataPopu evaluateWadeDataPopu = new EvaluateWadeDataPopu(CarEvaluateAddSubmitActivity.this,//
                                    ExtraValue.MODIFY_EVALUATE_CAR_WADE_SELECT,//
                                    mDataResources_wade);

                            evaluateWadeDataPopu.setTitleName(getResources().getString(R.string.choose_car_wade));

                            basePopupView_carWade = new XPopup.Builder(CarEvaluateAddSubmitActivity.this)
                                    .hasShadowBg(true)
                                    //.moveUpToKeyboard(false) //如果不加这个，评论弹窗会移动到软键盘上面;
                                    .isViewMode(true)
                                    //.autoDismiss(false)
                                    //.isDestroyOnDismiss(true) //对于只使用一次的弹窗，推荐设置这个
                                    //.isThreeDrag(false) //是否开启三阶拖拽，如果设置enableDrag(false)则无效
                                    //.dismissOnTouchOutside(true)
                                    //.notDismissWhenTouchInView()
                                    .asCustom(evaluateWadeDataPopu)//
                                    .show();

                        }
                    });

                }

                break;
            }

            case R.id.layoutevaluatepircetype: {//车辆的评估价格弹窗

                KeyboardUtils.hideSoftInput(mActivityInstance);

                ArrayList<EvaluateWadeInfo> tempList = new ArrayList<>();

                for (EvaluatePriceTypeInfo evaluatePriceTypeInfo : //
                        mDataResources_priceType) {
                    EvaluateWadeInfo evaluateWadeInfo = new EvaluateWadeInfo();
                    evaluateWadeInfo.setDictCode(evaluatePriceTypeInfo.getDictCode());
                    evaluateWadeInfo.setDictLabel(evaluatePriceTypeInfo.getDictLabel());
                    evaluateWadeInfo.setChecked(evaluatePriceTypeInfo.isChecked());
                    tempList.add(evaluateWadeInfo);
                }

                EvaluateWadePopu evaluateWadePopu = new EvaluateWadePopu(CarEvaluateAddSubmitActivity.this,//
                        ExtraValue.MODIFY_EVALUATE_CAR_PRICETYPE_SELECT,//
                        tempList);

                evaluateWadePopu.setTitleName(getResources().getString(R.string.plese_input_carmoney_type));

                basePopupView_carPriceType = new XPopup.Builder(CarEvaluateAddSubmitActivity.this)//
                        .hasShadowBg(true)//
                        .isViewMode(true)//
                        .asCustom(evaluateWadePopu)//
                        .show();

                break;
            }

            default:
                break;
        }

    }


    /**
     * 图片预览，兼容6.0动态权限
     */
    @AfterPermissionGranted(PRC_PHOTO_PREVIEW)
    private void photoPreviewWrapper() {

        if (mCurrentClickNpl == null) {
            return;
        }

        try {

            //do
            String[] perms = null;

//            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
            perms = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE};
//            } else {
//                perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE};
//            }

            if (EasyPermissions.hasPermissions(this, perms)) {

                CommTools.photoPreviewIntent(mActivityInstance, mActivityInstance, mCurrentClickNpl);

            } else {
                //EasyPermissions.requestPermissions(this, "图片预览需要以下权限:\n\n1.访问设备上的照片", PRC_PHOTO_PREVIEW, perms);
                EasyPermissions.requestPermissions(this, StringUtils.getString(R.string.imagenicelook), PRC_PHOTO_PREVIEW, perms);
            }

        } catch (Exception e) {
            //catch
            e.printStackTrace();
        }


    }

    private void photoPreviewIntentXXPermissions() {

        if (!XXPermissions.isGranted(CarEvaluateAddSubmitActivity.this, com.hjq.permissions.Permission.READ_MEDIA_IMAGES)) {

            CommUtils.checkMaterialDialog(materialDialog);

            materialDialog = CommUtils.authorityRequest(mActivityInstance, ConstantSign.MATERIALDIALOG_AUTHORITY_CONTENT_ALBUM, new AuthorityCallbackListener() {

                @Override
                public void doSomeThing() {

                    CommUtils.checkMaterialDialog(materialDialog);

                    XXPermissions.with(CarEvaluateAddSubmitActivity.this)
                            // 适配分区存储应该这样写
                            //.permission(Permission.Group.STORAGE)
                            // 不适配分区存储应该这样写
//                    .permission(com.hjq.permissions.Permission.CAMERA)//
                            .permission(com.hjq.permissions.Permission.READ_MEDIA_IMAGES)//
//                  .permission(com.hjq.permissions.Permission.READ_MEDIA_VIDEO)//
//                  .permission(com.hjq.permissions.Permission.READ_MEDIA_AUDIO)//
                            //).permission(com.hjq.permissions.Permission.MANAGE_EXTERNAL_STORAGE
                            .interceptor(new PermissionInterceptor())
                            .request(new OnPermissionCallback() {

                                @Override
                                public void onGranted(@NonNull List<String> permissions, boolean allGranted) {

                                    if (!allGranted) {
                                        return;
                                    }

                                    Toaster.show(String.format(getString(R.string.demo_obtain_permission_success_hint),
                                            PermissionNameConvert.getPermissionString(CarEvaluateAddSubmitActivity.this, permissions)));

                                    CommTools.photoPreviewIntent(mActivityInstance, mActivityInstance, mCurrentClickNpl);

                                }
                            });


                }
            });


        } else {

            CommTools.photoPreviewIntent(mActivityInstance, mActivityInstance, mCurrentClickNpl);

        }

    }

//    private void photoPreviewIntent() {
//
//        //File downloadDir = new File(Environment.getExternalStorageDirectory(), ConstantSign.BGAPHOTOPICKERDOWNLOAD);
//        File downloadDir = new File(PathUtils.getExternalAppFilesPath(), ConstantSign.BGAPHOTOPICKERDOWNLOAD);
//        BGAPhotoPreviewActivity.IntentBuilder photoPreviewIntentBuilder = new BGAPhotoPreviewActivity.IntentBuilder(this);
//
//        if (true) {
//            // 保存图片的目录，如果传 null，则没有保存图片功能
//            photoPreviewIntentBuilder.saveImgDir(downloadDir);
//        }
//
//        if (mCurrentClickNpl.getItemCount() == 1) {
//            // 预览单张图片
//            photoPreviewIntentBuilder.previewPhoto(mCurrentClickNpl.getCurrentClickItem());
//
//        } else if (mCurrentClickNpl.getItemCount() > 1) {
//            // 预览多张图片
//            photoPreviewIntentBuilder.previewPhotos(mCurrentClickNpl.getData())
//                    .currentPosition(mCurrentClickNpl.getCurrentClickItemPosition()); // 当前预览图片的索引
//        }
//
//        startActivity(photoPreviewIntentBuilder.build());
//
//    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mActivityInstance = this;

        processExtraData();

        initViews();

        //是否有调用接口取值的地方？获取车辆品牌和车系
        gainDatas();

        //监听品牌
        mCompositeDisposable.add(RxBus.getInstance()//
                .toObserverable(RxBusCarBrand.class)//
                .subscribeOn(AndroidSchedulers.mainThread())//
                .observeOn(AndroidSchedulers.mainThread())//
                .subscribe(new Consumer<RxBusCarBrand>() {//
                    @Override
                    public void accept(RxBusCarBrand rxBusCarBrand) throws Exception {

                        int actionFlag = rxBusCarBrand.getActionFlag();
                        CarBrandLargeCategory carBrandLargeCategory = rxBusCarBrand.getCarBrandLargeCategory();

                        if (actionFlag == ExtraValue.MODIFY_LEAD_CARBRAND_SELECT) {//更改了店铺信息和重新存储id等

                            if (carBrandLargeCategory != null) {

                                brandId_upLoad = carBrandLargeCategory.getCarBrandId();
//                                LogUtils.d("itchen---mCompositeDisposable---切换车辆品牌-->" + carBrandLargeCategory);

                                if (textViewBrandEvaluate != null) {
                                    textViewBrandEvaluate.setText(carBrandLargeCategory.getCarBrandName());
                                }

                                //--------------------------------------------------------------------
                                //车辆品牌一旦切换，车系必须清空重置重新选择
                                seriesId_upLoad = "";
                                if (textViewEvaluateBrandLine != null) {
                                    textViewEvaluateBrandLine.setText("");
                                }
                                if (mDataResources_carBrandSeriesList != null && !mDataResources_carBrandSeriesList.isEmpty()) {
                                    mDataResources_carBrandSeriesList.clear();
                                }

                                //----------------------------------------------------------------------------------------------

                                if (!TextUtils.isEmpty(brandId_upLoad)) {
                                    gainCarBrandSeriesLineSmallCategory(brandId_upLoad, null, false);
                                }

                                //----------------------------------------------------------------------------------------------

                            }
                        }
                    }
                }));

        //监听车系
        mCompositeDisposable.add(RxBus.getInstance()//
                .toObserverable(RxBusCarSeriesLineSmall.class)//
                .subscribeOn(AndroidSchedulers.mainThread())//
                .observeOn(AndroidSchedulers.mainThread())//
                .subscribe(new Consumer<RxBusCarSeriesLineSmall>() {//
                    @Override
                    public void accept(RxBusCarSeriesLineSmall rxBusCarSeriesLineSmall) throws Exception {

                        int actionFlag = rxBusCarSeriesLineSmall.getActionFlag();
                        CarBrandSeriesLineSmallCategory carBrandSeriesLineSmallCategory = rxBusCarSeriesLineSmall.getCarBrandSeriesLineSmallCategory();

                        if (actionFlag == ExtraValue.MODIFY_LEAD_CARBRAND_SERIES_SELECT) {//更改了店铺信息和重新存储id等

                            if (carBrandSeriesLineSmallCategory != null) {

                                //车系的id信息；
                                seriesId_upLoad = carBrandSeriesLineSmallCategory.getCarSeriesId();

//                                LogUtils.d("itchen---mCompositeDisposable---切换车辆品牌-车系-->" + carBrandSeriesLineSmallCategory);
                                if (textViewEvaluateBrandLine != null) {
                                    textViewEvaluateBrandLine.setText(carBrandSeriesLineSmallCategory.getCarSeriesName());
                                }
                            }
                        }
                    }
                }));

        //监听出厂日期
        mCompositeDisposable.add(RxBus.getInstance()
                .toObserverable(RxBusCalendarTime.class)//
                .subscribeOn(AndroidSchedulers.mainThread())//
                .observeOn(AndroidSchedulers.mainThread())//
                .subscribe(new Consumer<RxBusCalendarTime>() {

                    @Override
                    public void accept(RxBusCalendarTime rxBusCalendarTime) throws Throwable {

                        if (rxBusCalendarTime != null) {

                            if (rxBusCalendarTime.getActionFlag() == ExtraValue.RXBUS_EVALUATE_CAR_MANUFACTURE_TO_ADDSUBMIT) {//【出厂日期】时间；

                                //变动上传日期
                                releaseDate_upLoad = rxBusCalendarTime.getManufactureDate();

                                //修改文本
                                if (textViewStartTimeOutLine != null) {
                                    textViewStartTimeOutLine.setText(rxBusCalendarTime.getManufactureDate());
                                }

                            }
                        }
                    }
                }));

        //监听事故
        mCompositeDisposable.add(RxBus.getInstance()
                .toObserverable(RxBusCarProblem.class)//
                .subscribeOn(AndroidSchedulers.mainThread())//
                .observeOn(AndroidSchedulers.mainThread())//
                .subscribe(new Consumer<RxBusCarProblem>() {

                    @Override
                    public void accept(RxBusCarProblem rxBusCarProblem) throws Throwable {

                        if (rxBusCarProblem != null) {

                            if (rxBusCarProblem.getActionFlag() == ExtraValue.MODIFY_EVALUATE_CAR_PROBLEM_SELECT) {//【车辆事故的类型】；

                                //车辆事故的id
                                accident_upLoad = rxBusCarProblem.getEvaluateProblemInfo().getValue();

                                //修改文本
                                if (textViewCarInCidentOutSide != null) {
                                    textViewCarInCidentOutSide.setText(rxBusCarProblem.getEvaluateProblemInfo().getName());
                                }

                            }
                        }
                    }
                }));

        //监听涉水+
        mCompositeDisposable.add(RxBus.getInstance()
                .toObserverable(RxBusCarWadeData.class)//
                .subscribeOn(AndroidSchedulers.mainThread())//
                .observeOn(AndroidSchedulers.mainThread())//
                .subscribe(new Consumer<RxBusCarWadeData>() {

                    @Override
                    public void accept(RxBusCarWadeData rxBusCarWadeData) throws Throwable {

                        if (rxBusCarWadeData != null) {

                            if (rxBusCarWadeData.getActionFlag() == ExtraValue.MODIFY_EVALUATE_CAR_WADE_SELECT) {//【车辆涉水的类型】；

                                //车辆涉水的id
                                wade_upLoad = rxBusCarWadeData.getEvaluateWadeDataInfo().getValue();

                                //修改文本
                                if (textViewCarInWadeOutSide != null) {
                                    textViewCarInWadeOutSide.setText(rxBusCarWadeData.getEvaluateWadeDataInfo().getName());
                                }

                            }
                        }
                    }
                }));


        //监听报价类型
        mCompositeDisposable.add(RxBus.getInstance()
                .toObserverable(RxBusCarWade.class)//
                .subscribeOn(AndroidSchedulers.mainThread())//
                .observeOn(AndroidSchedulers.mainThread())//
                .subscribe(new Consumer<RxBusCarWade>() {

                    @Override
                    public void accept(RxBusCarWade rxBusCarWade) throws Throwable {

                        if (rxBusCarWade != null) {

                            if (rxBusCarWade.getActionFlag() == ExtraValue.MODIFY_EVALUATE_CAR_PRICETYPE_SELECT) {  //监听报价类型

                                //价格的类型
                                priceType_upLoad = rxBusCarWade.getEvaluateWadeInfo().getDictCode();

                                //价格的区间文本
                                if (textViewPriceForEvaluate != null) {
                                    textViewPriceForEvaluate.setText(rxBusCarWade.getEvaluateWadeInfo().getDictLabel());
                                }

                                //如果选择的是一口价，那么
                                if (TextUtils.equals(priceType_upLoad, EvalutePriceType.PRICETYPE_ONE_SINGLE.getIndex())) {

                                    linearLayoutSinglePrice.setVisibility(View.VISIBLE);
                                    linearLayoutMinAndMaxpPrice.setVisibility(View.GONE);


                                } else if (TextUtils.equals(priceType_upLoad, EvalutePriceType.PRICETYPE_TWO_RANGE.getIndex())) {
                                    //如果是价格区间，那么展示两个价格
                                    linearLayoutSinglePrice.setVisibility(View.GONE);
                                    linearLayoutMinAndMaxpPrice.setVisibility(View.VISIBLE);
                                }

                            }
                        }
                    }
                }));

        //图片配置初始化,因为有【二次编辑图片】
        initConfig();

        //添加页面刷新
//        if (!EventBus.getDefault().isRegistered(this)) {
//            EventBus.getDefault().register(this);
//        }

    }


    @Override
    protected int getContentViewId() {
        return R.layout.activity_car_evaluate_add_submit;
    }

    @Override
    protected void initToolBar(ToolbarHelper toolbarHelper) {

        //添加返回按钮
        //这个可能是动态的，不同身份 是不同标题：服务站经理存款业绩排名
        toolbarHelper.setTitle(getString(R.string.title_evaluate_car));
        toolbarHelper.setVersionName(true, AppUtils.getAppVersionName());
        toolbarHelper.setLayoutClose(false, "", null);
        toolbarHelper.setLayoutLeft(true, R.drawable.backicon, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                methodBack();
            }
        });

        toolbarHelper.setLayoutRight(false, 0, "", null);

//        toolbarHelper.setLayoutRight(true, 1, "历史记录", new ClickUtils.OnDebouncingClickListener() {
//            @Override
//            public void onDebouncingClick(View v) {
//                //历史记录的页面布局
//                Bundle extra_bundle = new Bundle();
//                ActivityUtils.startActivity(extra_bundle, WorkBookHistoryActivity.class);
//            }
//        });
    }

    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();

        ImmersionBar.with(this)//
                .titleBar(R.id.toolbarygxskout)
                .fitsSystemWindows(true)//解决状态栏和布局重叠问题，任选其一，默认为false，当为true时一定要指定statusBarColor()，不然状态栏为透明色，还有一些重载方法
                //.statusBarColor(R.color.colorPrimary)//
                //.navigationBarColor(R.color.colorPrimary)//
                //.keyboardEnable(true)
                .init();

    }

    @Override
    protected void onClickNodata(View v) {

    }

    @Override
    protected void initViews() {

        //选项的预备数据:跟进状态；
//        if (mDataResources_followUp == null) {
//            mDataResources_followUp = new ArrayList<>();
//        }
//        mDataResources_followUp.addAll(ViewUitls.getFollowUpInfoBeans());

        //事故的预备数据
        if (mDataResources_problem == null) {
            mDataResources_problem = new ArrayList<>();
        }
//        mDataResources_problem.addAll(ViewUitls.getProblemInfoBeans());

        //车辆涉水的拦截
        if (mDataResources_wade == null) {
            mDataResources_wade = new ArrayList<>();
        }
//        mDataResources_wade.addAll(ViewUitls.getWadeInfoBeans());

        //车辆评估价格的类型
        if (mDataResources_priceType == null) {
            mDataResources_priceType = new ArrayList<>();
        }
        mDataResources_priceType.addAll(ViewUitls.getPriceTypeInfoBeans());

        if (fileSingleUpLoadFiles_upLoad_hashMap == null) {
            fileSingleUpLoadFiles_upLoad_hashMap = new ArrayList<>();
        }

        if (fileSingleUpLoadFiles_modify_hashMap == null) {
            fileSingleUpLoadFiles_modify_hashMap = new ArrayList<>();
        }


        //中间的提交通用信息；
        //处理添加图片的监听
        mplimageListInEvaluate.setMaskProgressLayoutListener(new MaskProgressLayoutListener() {
            @Override
            public void onItemAdd(@NonNull View view, @NonNull MultiMediaView multiMediaView,
                                  int _alreadyImageCount,//
                                  int _alreadyVideoCount, //
                                  int _alreadyAudioCount) {//
                //alreadyImageCount, alreadyVideoCount, alreadyAudioCount

                alreadyImageCount = _alreadyImageCount;
                alreadyVideoCount = _alreadyVideoCount;
                alreadyAudioCount = _alreadyAudioCount;

                //直接的执行,仅仅拍照+录视频
                choicePhotoWrapper();

            }

            @Override
            public void onItemClick(@NonNull View view, @NonNull MultiMediaView multiMediaView) {

                //查看大图的
                // 点击详情,通过网页形式加载的数据，是加载不了详情数据的
//                LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult id:" + multiMediaView.getId());
//                LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult url:" + multiMediaView.getUrl());
//                LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 绝对路径:" + multiMediaView.getPath());
//                LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult Uri:" + multiMediaView.getUri());
//                LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 文件大小: " + multiMediaView.getSize());
//                LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 视频音频长度: " + multiMediaView.getDuration());
//
//                if (multiMediaView.isImageOrGif()) {
//                    if (multiMediaView.isImage()) {
//                        LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 图片类型");
//                    } else if (multiMediaView.isImage()) {
//                        LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 图片类型");
//                    }
//                } else if (multiMediaView.isVideo()) {
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 视频类型");
//                } else if (multiMediaView.isAudio()) {
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 音频类型");
//                }
//
//                LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 具体类型:" + multiMediaView.getMimeType());
//                LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 宽高: " + multiMediaView.getWidth() + "x" + multiMediaView.getHeight());

                if (multiMediaView != null) {
                    if (multiMediaView.isImageOrGif() || multiMediaView.isVideo()) {

                        if (mGlobalSetting != null && mplimageListInEvaluate != null) {
                            mGlobalSetting.openPreviewData(CarEvaluateAddSubmitActivity.this, REQUEST_CODE_CHOOSE,
                                    mplimageListInEvaluate.getImagesAndVideos(),
                                    mplimageListInEvaluate.getImagesAndVideos().indexOf(multiMediaView));
                        }

                    }
                }

            }

            @Override
            public void onItemStartUploading(@NonNull MultiMediaView multiMediaView) {

            }

            @Override
            public void onItemClose(@NonNull View view, @NonNull MultiMediaView multiMediaView) {

                //对图片的编辑；
                try {
                    //do
                    if (multiMediaView != null) {

                        if (extra_evaluate_detail_is_edit) {
                            //也有从本地重新加载图片的可能；
                            String fileLocalPath = multiMediaView.getPath();
//                            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "-是编辑过来的--fileLocalPath-->" + fileLocalPath);
                            //itchen-->---filePath-->/storage/emulated/0/middlelow/IMAGE_20230512_173801068.jpg

                            if (!TextUtils.isEmpty(fileLocalPath)) {
                                //说明是本地取出图片，编辑 删除 的是本地路径图片；
                                String getCurrentFileShortName = CommUtils.valueStringSplit(fileLocalPath);
                                if (fileSingleUpLoadFiles_upLoad_hashMap != null && !fileSingleUpLoadFiles_upLoad_hashMap.isEmpty()) {
                                    Iterator<HashMap<String, Object>> iterator = fileSingleUpLoadFiles_upLoad_hashMap.iterator();
                                    if (iterator != null) {
                                        while (iterator.hasNext()) {
                                            HashMap<String, Object> hashMapItem = iterator.next();
                                            if (hashMapItem != null) {
                                                String file_short_name_local_in_hashMap = (String) hashMapItem.get(Parameterkey.file_name);
                                                if (!TextUtils.isEmpty(getCurrentFileShortName) && !TextUtils.isEmpty(file_short_name_local_in_hashMap)) {
                                                    if (TextUtils.equals(getCurrentFileShortName, file_short_name_local_in_hashMap)) {
                                                        fileSingleUpLoadFiles_upLoad_hashMap.remove(hashMapItem);
                                                        LogUtils.json(ConstantSign.LOGCAT_NOMAL + "即将删除--新增的-本地数据-hashMapItem-->", hashMapItem);
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }

                            } else {

                                //【编辑】过来的，那么肯定只有url是有值的；
                                String fileUrl = multiMediaView.getUrl();
                                String getCurrentFileShortName = CommUtils.valueStringSplit(fileUrl);

                                if (fileSingleUpLoadFiles_upLoad_hashMap != null && !fileSingleUpLoadFiles_upLoad_hashMap.isEmpty()) {
                                    Iterator<HashMap<String, Object>> iterator = fileSingleUpLoadFiles_upLoad_hashMap.iterator();
                                    if (iterator != null) {
                                        while (iterator.hasNext()) {
                                            HashMap<String, Object> hashMapItem = iterator.next();
                                            if (hashMapItem != null) {
                                                String file_short_name_local_in_hashMap = (String) hashMapItem.get(Parameterkey.file_name);
                                                if (!TextUtils.isEmpty(getCurrentFileShortName) && !TextUtils.isEmpty(file_short_name_local_in_hashMap)) {
                                                    if (TextUtils.equals(getCurrentFileShortName, file_short_name_local_in_hashMap)) {
                                                        fileSingleUpLoadFiles_upLoad_hashMap.remove(hashMapItem);
                                                        LogUtils.json(ConstantSign.LOGCAT_NOMAL + "即将删除--在线url的名称 要上传的-hashMapItem-->", hashMapItem);
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                        } else {

                            //如果不是【编辑】，是正常的【添加】；
                            //是否要区分：是【添加图片】还是【从详情里取到的图片】，
                            String filePath = multiMediaView.getPath();
//                            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "---filePath-->" + filePath);
                            //itchen-->---filePath-->/storage/emulated/0/middlelow/IMAGE_20230512_173801068.jpg
                            String getCurrentFileShortName = CommUtils.valueStringSplit(filePath);

                            if (fileSingleUpLoadFiles_upLoad_hashMap != null && !fileSingleUpLoadFiles_upLoad_hashMap.isEmpty()) {
                                //遍历循环装载HashMap的list
                                Iterator<HashMap<String, Object>> iterator = fileSingleUpLoadFiles_upLoad_hashMap.iterator();
                                if (iterator != null) {
                                    while (iterator.hasNext()) {
                                        HashMap<String, Object> hashMapItem = iterator.next();
                                        if (hashMapItem != null) {
                                            String file_short_name_local = (String) hashMapItem.get(Parameterkey.file_name);
                                            if (!TextUtils.isEmpty(getCurrentFileShortName) && !TextUtils.isEmpty(file_short_name_local)) {
                                                if (TextUtils.equals(getCurrentFileShortName, file_short_name_local)) {
                                                    //同时间移除 记录的数组内容
                                                    fileSingleUpLoadFiles_upLoad_hashMap.remove(hashMapItem);
                                                    LogUtils.json(ConstantSign.LOGCAT_NOMAL + "即将删除--新增的-本地数据-hashMapItem-->", hashMapItem);
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            } else {
                                LogUtils.d(ConstantSign.LOGCAT_NOMAL + "fileSingleUpLoadFiles_upLoad_hashMap--onItemClose--是空的");
                            }


                        }


                        method_test_edit_update_hashMap();

                    }

                } catch (Exception e) {
                    //catch
                    e.printStackTrace();
                }

            }

            @Override
            public void onItemAudioStartDownload(@NonNull View view, @NonNull String s) {

            }

            @Override
            public boolean onItemVideoStartDownload(@NonNull View view, @NonNull MultiMediaView multiMediaView) {
                return false;
            }

            @Override
            public void onAddDataSuccess(@NonNull List<MultiMediaView> list) {

                //图片添加成功，那么
//                for (MultiMediaView item : list) {
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL + "item--item--item-->" + item.getUrl());
////                    LogUtils.d(ConstantSign.LOGCAT_NOMAL + "item--item--item-->" + item.getPath());
//
//                }

            }
        });

        //底部一个高度的帮助布局，因为遮挡了软键盘的评估备注；
        CommUtils.methodHelpView(textViewHelpiInEvaluateSubmitBottom);

    }


    @AfterPermissionGranted(PRC_PHOTO_PICKER)
//    private void choicePhotoWrapper(int alreadyImageCount, int alreadyVideoCount, int alreadyAudioCount) {
    private void choicePhotoWrapper() {

        try {
            //do

            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {

                String[] perms = {Manifest.permission.CAMERA, Permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};

                if (EasyPermissions.hasPermissions(this, perms)) {

                    openMain(alreadyImageCount, alreadyVideoCount, alreadyAudioCount);

                } else {
                    EasyPermissions.requestPermissions(this, StringUtils.getString(R.string.imageselectstr_audio), PRC_PHOTO_PICKER, perms);
                }

            } else {

//                String[] perms = {Permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
//                if (EasyPermissions.hasPermissions(this, perms)) {
//                    openMain(alreadyImageCount, alreadyVideoCount, alreadyAudioCount);
//                } else {
//                    EasyPermissions.requestPermissions(this, StringUtils.getString(R.string.imageselectstr_audio), PRC_PHOTO_PICKER, perms);
//                }

                //需要重新申请权限
                choicePhotoWrapperXXPermissions();

            }

        } catch (Exception e) {
            //catch
            e.printStackTrace();
        }

    }


    //使用XXPermissions改造
    private void choicePhotoWrapperXXPermissions() {

        if (!XXPermissions.isGranted(CarEvaluateAddSubmitActivity.this, com.hjq.permissions.Permission.CAMERA)
                || !XXPermissions.isGranted(CarEvaluateAddSubmitActivity.this, com.hjq.permissions.Permission.READ_MEDIA_IMAGES)) {

            CommUtils.checkMaterialDialog(materialDialog);

            materialDialog = CommUtils.authorityRequest(mActivityInstance, ConstantSign.MATERIALDIALOG_AUTHORITY_CONTENT_ALBUM, new AuthorityCallbackListener() {
                @Override
                public void doSomeThing() {

                    CommUtils.checkMaterialDialog(materialDialog);

                    XXPermissions.with(CarEvaluateAddSubmitActivity.this)
                            // 适配分区存储应该这样写
                            //.permission(Permission.Group.STORAGE)
                            // 不适配分区存储应该这样写
                            .permission(com.hjq.permissions.Permission.CAMERA)//
                            .permission(com.hjq.permissions.Permission.READ_MEDIA_IMAGES)//
//                                    .permission(com.hjq.permissions.Permission.READ_MEDIA_VIDEO)//
//                                    .permission(com.hjq.permissions.Permission.READ_MEDIA_AUDIO)//
                            //).permission(com.hjq.permissions.Permission.MANAGE_EXTERNAL_STORAGE
//                                                        .interceptor(new PermissionInterceptor())
                            .request(new OnPermissionCallback() {

                                @Override
                                public void onGranted(@NonNull List<String> permissions, boolean allGranted) {

                                    if (!allGranted) {
                                        // TODO: 2024/1/23 18:50 权限这里要不要给提示？权限没通过

                                        return;
                                    }

                                    Toaster.show(String.format(getString(R.string.demo_obtain_permission_success_hint),
                                            PermissionNameConvert.getPermissionString(CarEvaluateAddSubmitActivity.this, permissions)));

                                    openMain(alreadyImageCount, alreadyVideoCount, alreadyAudioCount);

                                }
                            });

                }
            });

        } else {

            openMain(alreadyImageCount, alreadyVideoCount, alreadyAudioCount);

        }

    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
    }


    /**
     * 公共的打开多媒体事件
     *
     * @param alreadyImageCount 已经存在的图片
     * @param alreadyVideoCount 已经存在的语音
     * @param alreadyAudioCount 已经存在的视频
     */
    private void openMain(int alreadyImageCount, int alreadyVideoCount, int alreadyAudioCount) {

        // 拍摄有关设置
        CameraSetting cameraSetting = new CameraSetting();
        // 支持的类型：图片，视频
        //cameraSetting.mimeTypeSet(MimeType.ofAll());
        cameraSetting.mimeTypeSet(MimeType.ofImage());

        // 相册
        AlbumSetting albumSetting = new AlbumSetting(false)
                // 支持的类型：图片，视频
                .mimeTypeSet(MimeType.ofImage())
                // 是否显示多选图片的数字
                .countable(true)
                // 自定义过滤器
                .addFilter(new GifSizeFilter(320, 320, 5 * BaseFilter.K * BaseFilter.K))
                // 开启原图
                .originalEnable(true)
                // 最大原图size,仅当originalEnable为true的时候才有效
                .maxOriginalSize(10);

        // 录音机
        //RecorderSetting recorderSetting = new RecorderSetting();

        // 全局
        mGlobalSetting = MultiMediaSetting.from(CarEvaluateAddSubmitActivity.this).choose(MimeType.ofImage());
        // 开启相册功能
        mGlobalSetting.albumSetting(albumSetting);

        // 开启拍摄功能
        mGlobalSetting.cameraSetting(cameraSetting);

//        if (mBinding.cbRecorder.isChecked()) {
//            // 开启录音功能
//            mGlobalSetting.recorderSetting(recorderSetting);
//        }

        mGlobalSetting
                // 设置路径和7.0保护路径等等
                .allStrategy(new SaveStrategy(true,//
                        ConstantSign.FILE_PROVIDER, //fileProvider
                        ConstantSign.FOLDER_MIDDLELOW))//
                .isImageEdit(false)
                // for glide-V4
                .imageEngine(new Glide4Engine())
                // 最大5张图片、最大3个视频、最大1个音频
                .maxSelectablePerMediaType(null,
                        ConstantApi.MAX_IMAGE_SELECTABLE,//5个图片，整体设置；
                        ConstantApi.MAX_VIDEO_SELECTABLE,
                        ConstantApi.MAX_AUDIO_SELECTABLE,
                        alreadyImageCount,
                        alreadyVideoCount,
                        alreadyAudioCount)
                .forResult(REQUEST_CODE_CHOOSE);

    }

    @Override
    protected void gainDatas() {

        if (NetworkUtils.isConnected()) {

            //根据不同跳转值判断 是哪种评估类型：
            if (TextUtils.equals(flag_jumpfrom_where_type, EvaluteCarEstimateType.ESTIMATE_TYPE_NEW_ADD_ONE.getIndex())) {

                //到店评估，-但是 又是一个 全新添加的评估；不需要获取详情；
                //gainDetailDatas();
                //其余的是通过,详情接口判断分发权限，【新添加的】只有【保存】的权限，
                CommUtils.setViewGone(layoutButtonEvaluateDispatch);

            } else if (TextUtils.equals(flag_jumpfrom_where_type, EvaluteCarEstimateType.ESTIMATE_TYPE_ONSTORE.getIndex())) {

                //到店评估，如果是【从详情过来的-编辑,或者是从主页列表过来的再次编辑】，需要获取详情，有一个基础信息填充所有值；
                if (extra_evaluate_detail_is_edit) {

                    gainDetailDatas();

                } else {

                    //到点评估，获取详情 是为了判断：分配用户的按钮，不做其他展示；
                    gainDetailDatas();

                }

            } else if (TextUtils.equals(flag_jumpfrom_where_type, EvaluteCarEstimateType.ESTIMATE_TYPE_ONDOOR.getIndex())) {

                //上门评估
                //上门评估，有填写车型 和 看车地点 和上门时间
                CommUtils.setViewVisible(lineLayoutCarModel);
                //看车地址展示
                CommUtils.setViewVisible(lineLayoutCarLookAddress);
                //上门时间展示
                CommUtils.setViewVisible(lineLayoutCarLookTime);

                //获取详情，填充上门信息
                gainDetailDatas();


            } else if (TextUtils.equals(flag_jumpfrom_where_type, EvaluteCarEstimateType.ESTIMATE_TYPE_ONLINE.getIndex())) {

                //在线评估
                //在线评估 需要调用接口，展示【车型】+【九宫格图片】
                CommUtils.setViewVisible(lineLayoutCarModel);
                CommUtils.setViewVisible(lineLayoutCarEvaluateOnLine);

                gainDetailDatas();

            } else if (TextUtils.equals(flag_jumpfrom_where_type, EvaluteCarEstimateType.ESTIMATE_TYPE_BOOKING.getIndex())) {

                //预约评估
                //预约评估-有姓名手机号，车辆车牌 车系 类型
                CommUtils.setViewVisible(lineLayoutCarModel);

                gainDetailDatas();

            }

        } else {
            //retain
        }

        //获取车辆的品牌信息
        gainCarBrandLargeCategory(null);

        //获取车辆的车系信息
        //gainCarBrandSeriesLineSmallCategory();

        //获取【车辆事故】的等级
        getListByType_problem_accident(null);

        //获取【车辆涉水】的等级
        getListByType_wade(null);


    }

    private void method_handler_middle_bottom_info_edit(EvaluateDetailItemBean _evaluateDetailItemBean) {

        //车辆品牌，这种仅仅遍历哪个品牌被选中即可
        //获取品牌，员工提交的车辆品牌
//        String brandId_server = _evaluateDetailItemBean.getBrandId();
        brandId_upLoad = _evaluateDetailItemBean.getBrandId();
        //车辆品牌 的真实名称
        //String brandName_server = _evaluateDetailItemBean.getBrandName();
        //设置【品牌】的匹配选中
//        for (CarBrandLargeCategory carBrandLargeCategoryItem : mDataResources_carBrandLarge) {
//            String brandId_item = carBrandLargeCategoryItem.getCarBrandId();
//            if (TextUtils.equals(brandId_server, brandId_item)) {
//                carBrandLargeCategoryItem.setChecked(true);
//            } else {
//                carBrandLargeCategoryItem.setChecked(false);
//            }
//        }
        CommUtils.setText(textViewBrandEvaluate, _evaluateDetailItemBean.getBrandName());

        //-----------------------------------------------------------------------------------------

        //车系 员工提交的
//        String seriesId_server = _evaluateDetailItemBean.getSeriesId();
        seriesId_upLoad = _evaluateDetailItemBean.getSeriesId();

        //车系名字-
        //String seriesName_server = _evaluateDetailItemBean.getSeriesName();
        //设置【车系】的匹配选中
//        for (CarBrandSeriesLineSmallCategory carBrandSeriesLineSmallCategoryItem: mDataResources_carBrandSeriesList) {
//            String brandId_item = carBrandSeriesLineSmallCategoryItem.getCarBrandId();
//            if (TextUtils.equals(seriesId_server,brandId_item)){
//                carBrandSeriesLineSmallCategoryItem.setChecked(true);
//            }else{
//                carBrandSeriesLineSmallCategoryItem.setChecked(false);
//            }
//        }
        CommUtils.setText(textViewEvaluateBrandLine, _evaluateDetailItemBean.getSeriesName());
        //-----------------------------------------------------------------------------------------
        //填充车型
        //String carModel = _evaluateDetailItemBean.getCarName();
        CommUtils.setText(editViewInputEvaluateCarModel, _evaluateDetailItemBean.getCarName());
        //-----------------------------------------------------------------------------------------
        //填充出厂日期 	"releaseDate":"2024-01-20",
        String releaseDate = CommUtils.getTimeHasNoMMddss(_evaluateDetailItemBean.getReleaseDate());
        //日期要格式化
        releaseDate_upLoad = CommUtils.getTimeHasNoMMddss(_evaluateDetailItemBean.getReleaseDate());
        CommUtils.setText(textViewStartTimeOutLine, releaseDate);
        //-----------------------------------------------------------------------------------------
        //填充公里数
        BigDecimal mileage = _evaluateDetailItemBean.getMileage();
        String mileageResult = "";
        if (mileage != null) {
            mileageResult = mileage.toString();
        } else {
            mileageResult = CommUtils.formatComma2BigDecimal(0.00).toString();
        }
        CommUtils.setText(editViewCarMileOutSide, mileageResult);
        //-----------------------------------------------------------------------------------------
        //填充颜色
        //String carColor = _evaluateDetailItemBean.getCarColor();
        CommUtils.setText(editViewCarInputColor, _evaluateDetailItemBean.getCarColor());
        //-----------------------------------------------------------------------------------------
        //填充【车辆事故】的id和文本值
        //String accident_server = _evaluateDetailItemBean.getAccident();
        //String accidentName_server = _evaluateDetailItemBean.getAccidentName();
        // : 2023-08-26 14:44 处理车辆事故和涉水的动态获取 ；
        accident_upLoad = _evaluateDetailItemBean.getAccident();
        CommUtils.setText(textViewCarInCidentOutSide, _evaluateDetailItemBean.getAccidentName());
        //-----------------------------------------------------------------------------------------
        //车辆的涉水
        //String wade = _evaluateDetailItemBean.getWade();
        wade_upLoad = _evaluateDetailItemBean.getWade();
        //String wadeName = _evaluateDetailItemBean.getWadeName();
        CommUtils.setText(textViewCarInWadeOutSide, _evaluateDetailItemBean.getWadeName());
        //-----------------------------------------------------------------------------------------
        //车辆的备注，中间的备注;
        if (editViewContentEvaluateRemark != null) {
            editViewContentEvaluateRemark.setText(_evaluateDetailItemBean.getRemark());
        }

        //-----------------------------------------------------------------------------------------
        //2023-08-26 15:27 附件，填充，并且可以编辑.
        //假如此刻用户恰恰没有处理附件，那么，直接填充内容就可以；
        //List<String> receptionImgs_server = _evaluateDetailItemBean.getReceptionImgs();

        //防止里边有null的链接出现，所以做一层过滤；
        List<String> receptionImgs_filter_after_result = new ArrayList<>();
        if (_evaluateDetailItemBean.getReceptionImgs() != null && !_evaluateDetailItemBean.getReceptionImgs().isEmpty()) {
            for (String itemHttpUrl : _evaluateDetailItemBean.getReceptionImgs()) {
                if (!TextUtils.isEmpty(itemHttpUrl) && !itemHttpUrl.contains(Parameterkey.null_value)) {
                    receptionImgs_filter_after_result.add(itemHttpUrl);
                }
            }
        }

        if (mplimageListInEvaluate != null) {
            mplimageListInEvaluate.setImageUrls(receptionImgs_filter_after_result);
        }

        //--------------------------------------------------------------------------------
        //处理上传用到的，用于编辑-主要指删除的
        String receptionImg_server = _evaluateDetailItemBean.getReceptionImg();

        if (!TextUtils.isEmpty(receptionImg_server)) {

            String[] arrList = receptionImg_server.split(",");

            if (arrList != null && arrList.length > 0) {

                for (String index : arrList) {
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL + "-receptionImg_server--->" + index);
                    //itchen-->-receptionImg_server--->image/estimate/20230825/2023082516292312511447.jpg
                    if (!TextUtils.isEmpty(index)) {//必须判断，后台接口有null出现；
                        if (!TextUtils.equals(index, Parameterkey.null_value)) {
                            HashMap<String, Object> hashMapTemp = new HashMap<>();
                            hashMapTemp.put(Parameterkey.file_name, CommUtils.valueStringSplit(index));
                            hashMapTemp.put(Parameterkey.file_path_server, index);

                            if (fileSingleUpLoadFiles_upLoad_hashMap != null) {
                                fileSingleUpLoadFiles_upLoad_hashMap.add(hashMapTemp);
                            }
                        }
                    }
                }
            }
        }

        //--------------------------------------------------------------------------------

        method_test_upLoadHashMap();

//        ArrayList<MultiMediaView> multiMediaViewArrayList = mplimageListInEvaluate.getImages();
//        if (multiMediaViewArrayList != null && !multiMediaViewArrayList.isEmpty()) {
//
//            for (MultiMediaView multiMediaView : multiMediaViewArrayList) {
//
//                if (multiMediaView != null) {
//                    String localPath = multiMediaView.getPath();
//                    String getOriginalPath = multiMediaView.getOriginalPath();
//                    String getOldPath = multiMediaView.getOldPath();
//                    Uri getUri = multiMediaView.getUri();
//                    String getUrl = multiMediaView.getUrl();
//
//                    //LogUtils.d(ConstantSign.LOGCAT_NOMAL + "-MultiMediaView---localPath-->" + localPath);
////                    LogUtils.d(ConstantSign.LOGCAT_NOMAL + "-MultiMediaView---getOriginalPath-->" + getOriginalPath);
////                    LogUtils.d(ConstantSign.LOGCAT_NOMAL + "-MultiMediaView---getOldPath-->" + getOldPath);
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL + "-MultiMediaView---getUrl-->" + getUrl);
//
////                    if (getUri != null) {
////                        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "-MultiMediaView---getUri-->" + getUri.getPath());
////                    }
//
//                } else {
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL + "-MultiMediaView---multiMediaView--> 是空值");
//                }
//
//            }
//
//        }

        //-----------------------------------------------------------------------------------------
        //报价类型
        String priceType = _evaluateDetailItemBean.getPriceType();
        //最低价格
        BigDecimal minPrice = _evaluateDetailItemBean.getMinPrice();

        BigDecimal maxPrice = _evaluateDetailItemBean.getMaxPrice();

        //循环遍历 价格类型的选中
        for (EvaluatePriceTypeInfo evaluatePriceTypeInfo : mDataResources_priceType) {
            String type_item = evaluatePriceTypeInfo.getDictCode();
            if (TextUtils.equals(type_item, priceType)) {
                evaluatePriceTypeInfo.setChecked(true);
            } else {
                evaluatePriceTypeInfo.setChecked(false);
            }
        }

//        public enum EvalutePriceType {
//            PRICETYPE_ONE_SINGLE("1", "一口价"),
//            PRICETYPE_TWO_RANGE("2", "区间价");
        if (TextUtils.equals(priceType, EvalutePriceType.PRICETYPE_ONE_SINGLE.getIndex())) {

            CommUtils.setText(textViewPriceForEvaluate, EvalutePriceType.PRICETYPE_ONE_SINGLE.getValue());

            linearLayoutSinglePrice.setVisibility(View.VISIBLE);
            linearLayoutMinAndMaxpPrice.setVisibility(View.GONE);

            //展示一口价
            String minPriceString = "";
            if (minPrice != null) {
                minPriceString = minPrice.toString();
                minPrice_upLoad = minPrice.toString();
            } else {
                minPriceString = CommUtils.formatComma2BigDecimal(0.00).toString();
                minPrice_upLoad = CommUtils.formatComma2BigDecimal(0.00).toString();
            }
            maxPrice_upLoad = minPrice_upLoad;
            //普通的一口价的性质
            CommUtils.setText(editViewEvaluatePrice, minPriceString);

        } else if (TextUtils.equals(priceType, EvalutePriceType.PRICETYPE_TWO_RANGE.getIndex())) {

            CommUtils.setText(textViewPriceForEvaluate, EvalutePriceType.PRICETYPE_TWO_RANGE.getValue());

            //如果是价格区间，那么展示两个价格
            linearLayoutSinglePrice.setVisibility(View.GONE);
            linearLayoutMinAndMaxpPrice.setVisibility(View.VISIBLE);

            String minPriceString = "";
            if (minPrice != null) {
                minPriceString = minPrice.toString();
                minPrice_upLoad = minPrice.toString();
            } else {
                minPriceString = CommUtils.formatComma2BigDecimal(0.00).toString();
                minPrice_upLoad = CommUtils.formatComma2BigDecimal(0.00).toString();
            }

            String maxPriceString = "";

            if (minPrice != null) {
                maxPriceString = maxPrice.toString();
                maxPrice_upLoad = maxPrice.toString();
            } else {
                maxPriceString = CommUtils.formatComma2BigDecimal(0.00).toString();
                maxPrice_upLoad = CommUtils.formatComma2BigDecimal(0.00).toString();
            }

            //设置最低价
            CommUtils.setText(editViewEvaluateMinPrice, minPriceString);
            //设置最高价
            CommUtils.setText(editViewEvaluateMaxPrice, maxPriceString);

        }

        //-----------------------------------------------------------------------------------------------------
        //评估的备注
        if (editViewEvaluateBottomRemark != null) {
            editViewEvaluateBottomRemark.setText(_evaluateDetailItemBean.getPriceRemark());
        }
        //-----------------------------------------------------------------------------------------------------

    }

    //仅仅是处理头部信息；不同状态头部处理不同。
    private void method_handler_top_info_success(EvaluateDetailItemBean _evaluateDetailItemBean) {

        //这里需要重新赋值主键的id
        if (!TextUtils.isEmpty(_evaluateDetailItemBean.getEstimateId())) {
            extra_evalute_current_item_bean.setEstimateId(_evaluateDetailItemBean.getEstimateId());
        }

//        特别注意：这里不能加东西，有什么值，就填充什么值，上传的时候一块携带；
//        ArrayList<String> receptionImg_temp = (ArrayList<String>) _evaluateDetailItemBean.getReceptionImgs();

//        if (receptionImg_upLoad != null && !receptionImg_upLoad.isEmpty()) {
//            receptionImg_upLoad.clear();
//        }

//        if (receptionImg_temp != null && !receptionImg_temp.isEmpty()) {
//            receptionImg_upLoad.addAll(receptionImg_temp);
//        }

        receptionImg_upLoad = _evaluateDetailItemBean.getReceptionImg();

        //上门时间和上门地址，填充
//        doorTime_upLoad = _evaluateDetailItemBean.getDoorTime();
//        address_upLoad = _evaluateDetailItemBean.getAddress();

//        public enum EvaluteCarEstimateType {
//            ESTIMATE_TYPE_ONLINE("1", "在线评估"),
//            ESTIMATE_TYPE_BOOKING("2", "预约评估"),
//            ESTIMATE_TYPE_ONDOOR("3", "上门评估"),
//            ESTIMATE_TYPE_ONSTORE("4", "到店评估");

        if (TextUtils.equals(flag_jumpfrom_where_type, EvaluteCarEstimateType.ESTIMATE_TYPE_BOOKING.getIndex())) {
            //预约评估
            //用户姓名：
            String customerName = _evaluateDetailItemBean.getCustomerName();
            //用户手机号
            String customerPhone = _evaluateDetailItemBean.getCustomerPhone();

            //在线评估
            String cardBrand = _evaluateDetailItemBean.getCarBrandName();
            //车辆车系
            String brandLineSecond = _evaluateDetailItemBean.getCarSeriesName();
            //车辆车型
            String model = _evaluateDetailItemBean.getVehicleName();
            //用户姓名
            CommUtils.setText(editViewNameValuate, customerName);
            //用户手机号
            CommUtils.setText(editViewPhoneEvaluate, customerPhone);
            //车辆的品牌信息
            CommUtils.setText(textViewPersonCarModel, cardBrand + getString(R.string.kongge0) + brandLineSecond + getString(R.string.kongge0) + model);

        } else if (TextUtils.equals(flag_jumpfrom_where_type, EvaluteCarEstimateType.ESTIMATE_TYPE_ONSTORE.getIndex())) {
            //到店评估
            //bug:2024年1月19日17:17:08 发现这里的bug:顶部姓名和手机号未填充
            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "是到店评估-->EvaluteCarEstimateType.ESTIMATE_TYPE_ONSTORE.getIndex()");

            //顶部有姓名和手机号信息
            //用户姓名：
            String customerName = _evaluateDetailItemBean.getCustomerName();
            //用户手机号
            String customerPhone = _evaluateDetailItemBean.getCustomerPhone();
            //用户姓名
            CommUtils.setText(editViewNameValuate, customerName);
            //用户手机号
            CommUtils.setText(editViewPhoneEvaluate, customerPhone);


        } else if (TextUtils.equals(flag_jumpfrom_where_type, EvaluteCarEstimateType.ESTIMATE_TYPE_ONDOOR.getIndex())) {
            //上门评估
            //用户姓名：
            String customerName = _evaluateDetailItemBean.getCustomerName();
            //用户手机号
            String customerPhone = _evaluateDetailItemBean.getCustomerPhone();

            //在线评估
            String cardBrand = _evaluateDetailItemBean.getCarBrandName();
            //车辆车系
            String brandLineSecond = _evaluateDetailItemBean.getCarSeriesName();
            //车辆车型
            String model = _evaluateDetailItemBean.getVehicleName();
            //用户姓名
            CommUtils.setText(editViewNameValuate, customerName);
            //用户手机号
            CommUtils.setText(editViewPhoneEvaluate, customerPhone);
            //车辆的品牌信息
            CommUtils.setText(textViewPersonCarModel, cardBrand + getString(R.string.kongge0) + brandLineSecond + getString(R.string.kongge0) + model);

            //------------------------------------------------------------

            //看车地址
            String address = _evaluateDetailItemBean.getAddress();
            CommUtils.setText(textViewPersonLookCarAddress, address);

            //上门时间
            String doorTime = _evaluateDetailItemBean.getDoorTime();
            CommUtils.setText(textViewPersonLookCarTime, doorTime);

        } else if (TextUtils.equals(flag_jumpfrom_where_type, EvaluteCarEstimateType.ESTIMATE_TYPE_ONLINE.getIndex())) {

            //用户姓名：
            String customerName = _evaluateDetailItemBean.getCustomerName();
            //用户手机号
            String customerPhone = _evaluateDetailItemBean.getCustomerPhone();

            //在线评估
            String cardBrand = _evaluateDetailItemBean.getCarBrandName();
            //车辆车系
            String brandLineSecond = _evaluateDetailItemBean.getCarSeriesName();
            //车辆车型
            String model = _evaluateDetailItemBean.getVehicleName();

            //用户姓名
            CommUtils.setText(editViewNameValuate, customerName);
            //用户手机号
            CommUtils.setText(editViewPhoneEvaluate, customerPhone);

            //------------------------------------------------------------
            //车辆的品牌信息
            CommUtils.setText(textViewPersonCarModel, cardBrand + getString(R.string.kongge0) + brandLineSecond + getString(R.string.kongge0) + model);

            //九宫格，小程序端提交的图片--是客户自己提交的图片信息
            ArrayList<String> customerImages = (ArrayList<String>) _evaluateDetailItemBean.getCustomerImgs();
            //如果有图片，就展示九宫格，没有图片就不展示；
            if (customerImages != null && !customerImages.isEmpty()) {
                CommUtils.setViewVisible(lineLayoutCarEvaluateOnLine);
            } else {
                CommUtils.setViewGone(lineLayoutCarEvaluateOnLine);
            }

            if (npl_item_moment_photos != null) {
                npl_item_moment_photos.setData(customerImages);
                //设置代理
                npl_item_moment_photos.setDelegate(new BGANinePhotoLayout.Delegate() {
                    @Override
                    public void onClickNinePhotoItem(BGANinePhotoLayout ninePhotoLayout, View view, int position, String model, List<String> models) {
                        //点击九宫格,查看大图
                        mCurrentClickNpl = ninePhotoLayout;

                        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
                            photoPreviewWrapper();
                        } else {
                            photoPreviewIntentXXPermissions();
                        }

                    }

                    @Override
                    public void onClickExpand(BGANinePhotoLayout ninePhotoLayout, View view, int position, String model, List<String> models) {
                        //点击展开的
                        ninePhotoLayout.setIsExpand(true);
                        ninePhotoLayout.flushItems();
                    }
                });
            }

        }

    }

    //获取数据详情，因该是不论任何类型的评估的。
    private void gainDetailDatas() {

        //添加是
        String estimateId = "";
        if (extra_evalute_current_item_bean != null) {
            estimateId = extra_evalute_current_item_bean.getEstimateId();
        }

        HashMap<String, Object> map = new HashMap<>();
        map.put(Parameterkey.estimateId, estimateId);

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_ESTIMATE_GETBYID);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.estimate_getById_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_GET);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
        addLogUpLoadInfo.setHashMapParameter(map);

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                //.getById(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue), MediaType.parse(ApiService.HEADER_JSON)))
                .estimate_getById(estimateId)
                .compose(CarEvaluateAddSubmitActivity.this.bindUntilEvent(ActivityEvent.DESTROY))
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<EvaluateDetailItemBean>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);
                        //如果出问题这里要遮盖
                    }
                })).subscribe(new Consumer<EvaluateDetailItemBean>() {
                    @Override
                    public void accept(EvaluateDetailItemBean evaluateDetailItemBean) throws Throwable {

                        //主要是顶部变动
                        if (evaluateDetailItemBean != null) {

                            method_handler_top_info_success(evaluateDetailItemBean);


                            //如果是从【评估详情】-【编辑】过来的，那么还需要填充底部信息
                            if (extra_evaluate_detail_is_edit) {
                                method_handler_middle_bottom_info_edit(evaluateDetailItemBean);
                            }


                            //权限的判断：
                            //是否具备有【分配客户】的权限；
                            //判断是哪种评估，并且先获取详情来展示顶部基础信息：
                            //是否是具备【分配客户】权限,携带的列表分配不行，
                            int isSend = evaluateDetailItemBean.getIsSend();

                            // TODO: 2023-08-27 这个权限的判断是否在 编辑 状态下 也要有？还是说 编辑 就只能 是编辑，不能分配；

                            // : 2023-08-10 15:37 分开权限，以从详情获取的为准；
                            if (isSend == SendType.SEND_YES.getValue()) {
                                //有分发能力
                                CommUtils.setViewVisible(layoutButtonEvaluateDispatch);

                            } else if (isSend == SendType.SEND_NO.getValue()) {

                                //没有分发能力
                                CommUtils.setViewGone(layoutButtonEvaluateDispatch);

                            }

                        }

                    }
                }, new ErrorConsumer() {
                    @Override
                    protected void error(ApiException apiException) {
                        //
                    }
                });

    }

    //获取 涉水 列表
    private void getListByType_wade(GainDataCallBackListener _gainDataCallBackListener) {

        HashMap<String, Object> map = new HashMap<>();
        map.put(Parameterkey.wadeType, Parameterkey.wadeType);

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_GETLISTBYTYPE_ACCIDENT_URL);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.getListByType_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
        addLogUpLoadInfo.setHashMapParameter(map);

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                .getListByType_wade(Parameterkey.wadeType)
                .compose(CarEvaluateAddSubmitActivity.this.bindUntilEvent(ActivityEvent.DESTROY))
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<ArrayList<EvaluateWadeDataInfo>>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);
                    }
                })).subscribe(new Consumer<ArrayList<EvaluateWadeDataInfo>>() {
                    @Override
                    public void accept(ArrayList<EvaluateWadeDataInfo> evaluateWadeInfos) throws Throwable {

                        //将手动本地填充的清空也行；
                        if (mDataResources_wade != null && !mDataResources_wade.isEmpty()) {
                            mDataResources_wade.clear();
                        }

                        if (evaluateWadeInfos != null && !evaluateWadeInfos.isEmpty()) {

                            if (mDataResources_wade != null) {
                                mDataResources_wade.addAll(evaluateWadeInfos);

                                //如果是【编辑】，那么
                                if (extra_evaluate_detail_is_edit) {

                                    if (!TextUtils.isEmpty(wade_upLoad)) {

                                        for (EvaluateWadeDataInfo evaluateWadeDataInfo : mDataResources_wade) {

                                            String wade_item = evaluateWadeDataInfo.getValue();

                                            if (TextUtils.equals(wade_item, wade_upLoad)) {
                                                evaluateWadeDataInfo.setChecked(true);
                                            } else {
                                                evaluateWadeDataInfo.setChecked(false);
                                            }

                                        }

                                    }
                                }
                            }
                        }

                        if (_gainDataCallBackListener != null) {
                            _gainDataCallBackListener.doSomeThing();
                        }

                    }
                }, new ErrorConsumer() {

                    @Override
                    protected void error(ApiException apiException) {
                        //
                    }
                });

    }

    //获取 车辆 事故列表
    private void getListByType_problem_accident(GainDataCallBackListener _gainDataCallBackListener) {

        HashMap<String, Object> map = new HashMap<>();
        map.put(Parameterkey.accidentType, Parameterkey.accidentType);

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_GETLISTBYTYPE_ACCIDENT_URL);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.getListByType_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
        addLogUpLoadInfo.setHashMapParameter(map);

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                .getListByType_accident(Parameterkey.accidentType)
                .compose(CarEvaluateAddSubmitActivity.this.bindUntilEvent(ActivityEvent.DESTROY))
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<ArrayList<EvaluateProblemInfo>>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);
                    }
                })).subscribe(new Consumer<ArrayList<EvaluateProblemInfo>>() {
                    @Override
                    public void accept(ArrayList<EvaluateProblemInfo> evaluateProblemInfos) throws Throwable {

                        if (mDataResources_problem != null && !mDataResources_problem.isEmpty()) {
                            mDataResources_problem.clear();
                        }

                        if (evaluateProblemInfos != null && !evaluateProblemInfos.isEmpty()) {

                            if (mDataResources_problem != null) {
                                mDataResources_problem.addAll(evaluateProblemInfos);

                                //如果是【编辑】，那么
                                if (extra_evaluate_detail_is_edit) {

                                    if (!TextUtils.isEmpty(accident_upLoad)) {

                                        for (EvaluateProblemInfo evaluateProblemInfo : mDataResources_problem) {

                                            String accident_item = evaluateProblemInfo.getValue();

                                            if (TextUtils.equals(accident_item, accident_upLoad)) {
                                                evaluateProblemInfo.setChecked(true);
                                            } else {
                                                evaluateProblemInfo.setChecked(false);
                                            }

                                        }

                                    }
                                }
                            }
                        }

                        //做一次转换为了做合同弹窗的
                        if (_gainDataCallBackListener != null) {
                            _gainDataCallBackListener.doSomeThing();
                        }

                    }
                }, new ErrorConsumer() {

                    @Override
                    protected void error(ApiException apiException) {
                        //
                    }
                });

    }

    //获取车辆的品牌--大范畴--并且是获取所有品牌的车辆
    private void gainCarBrandLargeCategory(GainDataCallBackListener _gainDataCallBackListener) {

        //
        HashMap<String, Object> map = new HashMap<>();
        //map.put(Parameterkey., yourName);

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_GETCARBRANDLIST_URL);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.getCarBrandList_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(true);//展示给用户的标志
        addLogUpLoadInfo.setHashMapParameter(map);

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                .getCarBrandList(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
                        MediaType.parse(ApiService.HEADER_JSON)))
                .compose(CarEvaluateAddSubmitActivity.this.bindUntilEvent(ActivityEvent.DESTROY))
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<ArrayList<CarBrandLargeCategory>>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);
                    }
                })).doOnSubscribe(new Consumer<Disposable>() {
                    @Override
                    public void accept(Disposable disposable) throws Throwable {

                        CarBrandLargeCategoryDaoManager.getInstance().deleteAllCarBrand();

                        method_create_materialDialog(mActivityInstance, ConstantSign.TIPS_LOADING);

                    }
                }).subscribe(new Consumer<ArrayList<CarBrandLargeCategory>>() {
                    @Override
                    public void accept(ArrayList<CarBrandLargeCategory> carBrandLargeCategories) throws Throwable {

                        if (mDataResources_carBrandLarge != null && !mDataResources_carBrandLarge.isEmpty()) {
                            mDataResources_carBrandLarge.clear();
                        }

                        if (carBrandLargeCategories != null && !carBrandLargeCategories.isEmpty()) {

                            if (mDataResources_carBrandLarge != null) {

                                mDataResources_carBrandLarge.addAll(carBrandLargeCategories);
                                //重新排序
                                CommUtils.CollectionsSort_CarBrandLargeCategory_CHINA(mDataResources_carBrandLarge);
                                //直接存入本地数据库，要删除重新录入吗？可能切换店铺等；
                                CarBrandLargeCategoryDaoManager.getInstance().insertMultCarBrand(mDataResources_carBrandLarge);


                                //也就是 说或者是 编辑过来的，那么就执行这个操作
                                if (extra_evaluate_detail_is_edit) {

                                    if (!TextUtils.isEmpty(brandId_upLoad)) {

                                        for (CarBrandLargeCategory carBrandLargeCategoryItem : mDataResources_carBrandLarge) {
                                            String brandId_item = carBrandLargeCategoryItem.getCarBrandId();
                                            if (TextUtils.equals(brandId_upLoad, brandId_item)) {
                                                carBrandLargeCategoryItem.setChecked(true);
                                            } else {
                                                carBrandLargeCategoryItem.setChecked(false);
                                            }
                                        }

                                        //直接调用-此品牌的【车系】列表；
                                        gainCarBrandSeriesLineSmallCategory(brandId_upLoad, null, false);

                                    }

                                }
                            }

                        }

                        CommUtils.checkMaterialDialog(materialDialog);

                        //立即获取车系？没有必要
                        if (_gainDataCallBackListener != null) {
                            _gainDataCallBackListener.doSomeThing();
                        }

                    }
                }, new ErrorConsumer() {

                    @Override
                    protected void error(ApiException apiException) {
                        CommUtils.checkMaterialDialog(materialDialog);
                    }
                });

    }

    //获取车辆的车系--小范畴
    private void gainCarBrandSeriesLineSmallCategory(String _carBrandId, GainDataCallBackListener _gainDataCallBackListener, boolean isAutoAlert) {

        //
        HashMap<String, Object> map = new HashMap<>();
        map.put(Parameterkey.carBrandId, _carBrandId);

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_GETCARSERIESLIST);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.getCarSeriesList_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(true);
        addLogUpLoadInfo.setAlertToUser(true);//特殊提示
        addLogUpLoadInfo.setHashMapParameter(map);

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                .getCarSeriesList(RequestBody.create(JSON.toJSONString(map, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue),
                        MediaType.parse(ApiService.HEADER_JSON)))
                .compose(CarEvaluateAddSubmitActivity.this.bindUntilEvent(ActivityEvent.DESTROY))
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<ArrayList<CarBrandSeriesLineSmallCategory>>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);

                        CommUtils.checkMaterialDialog(materialDialog);

                        //无数据要提示
                        //{"data":"","message":"无数据","code":"20002"}

                        //选择完毕品牌，自动调用接口带出车系，如果自动带出无数据就给提示
                        if (isAutoAlert) {
                            function_response_20002(serverCode, serverMessage, addLogUpLoadInfo, false);
                        }

                    }
                })).doOnSubscribe(new Consumer<Disposable>() {
                    @Override
                    public void accept(Disposable disposable) throws Throwable {

                        //清空
                        CarBrandSeriesLineDaoManager.getInstance().deleteAllCarSeries();

                        if (_gainDataCallBackListener != null) {
                            method_create_materialDialog(mActivityInstance, ConstantSign.TIPS_LOADING);
                        }

                    }
                }).subscribe(new Consumer<ArrayList<CarBrandSeriesLineSmallCategory>>() {
                    @Override
                    public void accept(ArrayList<CarBrandSeriesLineSmallCategory> carBrandSeriesLineSmallCategories) throws Throwable {

                        CommUtils.checkMaterialDialog(materialDialog);

                        if (mDataResources_carBrandSeriesList != null && !mDataResources_carBrandSeriesList.isEmpty()) {
                            mDataResources_carBrandSeriesList.clear();
                        }

                        if (carBrandSeriesLineSmallCategories != null && !carBrandSeriesLineSmallCategories.isEmpty()) {

                            if (mDataResources_carBrandSeriesList != null) {
                                mDataResources_carBrandSeriesList.addAll(carBrandSeriesLineSmallCategories);

                                //先排序
//                                CommUtils.CollectionsSort_CarBrandSeriesLineSmallCategory_UK(mDataResources_carBrandSeriesList);
                                CommUtils.CollectionsSort_CarBrandSeriesLineSmallCategory_CHINA(mDataResources_carBrandSeriesList);
                                //filldatas
                                CarBrandSeriesLineDaoManager.getInstance().insertMultCarSeries(mDataResources_carBrandSeriesList);


                                if (extra_evaluate_detail_is_edit) {

                                    //侧面也表示 是【编辑】过来的，那么就填充勾选
                                    if (!TextUtils.isEmpty(seriesId_upLoad)) {

                                        //设置【车系】的匹配选中;
                                        for (CarBrandSeriesLineSmallCategory carBrandSeriesLineSmallCategoryItem : mDataResources_carBrandSeriesList) {

                                            String carSeriesId_item = carBrandSeriesLineSmallCategoryItem.getCarSeriesId();

                                            if (TextUtils.equals(seriesId_upLoad, carSeriesId_item)) {
                                                carBrandSeriesLineSmallCategoryItem.setChecked(true);
                                            } else {
                                                carBrandSeriesLineSmallCategoryItem.setChecked(false);
                                            }

                                        }

                                    }

                                }

                            }
                        }

                        if (_gainDataCallBackListener != null) {
                            _gainDataCallBackListener.doSomeThing();
                        }

                    }
                }, new ErrorConsumer() {

                    @Override
                    protected void error(ApiException apiException) {
                        CommUtils.checkMaterialDialog(materialDialog);
                    }
                });

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (resultCode != RESULT_OK) {
            return;
        }

        if (requestCode == REQUEST_CODE_CHOOSE) {

            // 如果是在预览界面点击了确定
            if (data.getBooleanExtra(BasePreviewActivity.EXTRA_RESULT_APPLY, false)) {

                // 获取选择的数据
                ArrayList<MultiMedia> selected = MultiMediaSetting.obtainMultiMediaResult(data);
//                LogUtils.d(ConstantSign.LOGCAT_NOMAL + "--selected--的值内容-->" + selected);

                if (selected == null) {
                    return;
                }

                // 循环判断，如果不存在，则删除
                for (int i = mplimageListInEvaluate.getImagesAndVideos().size() - 1; i >= 0; i--) {

                    int k = 0;

                    for (MultiMedia multiMedia : selected) {
                        if (!mplimageListInEvaluate.getImagesAndVideos().get(i).equals(multiMedia)) {
                            k++;
                        }
                    }

                    if (k == selected.size()) {
                        // 所有都不符合，则删除
                        mplimageListInEvaluate.removePosition(i);
                    }

                }

            } else {
                List<LocalFile> result = MultiMediaSetting.obtainLocalFileResult(data);
                ArrayList<String> listUpLoad = new ArrayList<>();
                for (LocalFile localFile : result) {
                    // 绝对路径,AndroidQ如果存在不属于自己App下面的文件夹则无效
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult id:" + localFile.getId());
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 绝对路径:" + localFile.getPath());
                    //---/storage/emulated/0/middlelow/IMAGE_20230404_155336703.jpg
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 旧图路径:" + localFile.getOldPath());
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 原图路径:" + localFile.getOriginalPath());
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult Uri:" + localFile.getUri());
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 旧图Uri:" + localFile.getOldUri());
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 原图Uri:" + localFile.getOriginalUri());
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 文件大小: " + localFile.getSize());
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 视频音频长度: " + localFile.getDuration());
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 是否选择了原图: " + localFile.isOriginal());
//                    if (localFile.isImageOrGif()) {
//                        if (localFile.isImage()) {
//                            LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 图片类型");
//                        } else if (localFile.isImage()) {
//                            LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 图片类型");
//                        }
//                    } else if (localFile.isVideo()) {
//                        LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 视频类型");
//                    } else if (localFile.isAudio()) {
//                        LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 音频类型");
//                    }
//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 具体类型:" + localFile.getMimeType())
                    // 某些手机拍摄没有自带宽高，那么我们可以自己获取
//                    if (localFile.getWidth() == 0 && localFile.isVideo()) {
//                        MediaExtraInfo mediaExtraInfo = MediaUtils.getVideoSize(getApplication(), localFile.getPath());
//                        localFile.setWidth(mediaExtraInfo.getWidth());
//                        localFile.setHeight(mediaExtraInfo.getHeight());
//                        localFile.setDuration(mediaExtraInfo.getDuration());
//                    }

//                    LogUtils.d(ConstantSign.LOGCAT_NOMAL, "onResult 宽高: " + localFile.getWidth() + "x" + localFile.getHeight());
                    // method_single_image_addSubmit_upLoad(localFile.getPath());

                    if (!TextUtils.isEmpty(localFile.getPath())) {
                        listUpLoad.add(localFile.getPath());
                    }

                    //直接 存储
                    HashMap<String, Object> hashMapTemp = new HashMap<String, Object>();
                    hashMapTemp.put(Parameterkey.file_name, CommUtils.valueStringSplit(localFile.getPath()));
                    hashMapTemp.put(Parameterkey.file_path_local, localFile.getPath());

                    if (fileSingleUpLoadFiles_upLoad_hashMap != null) {
                        fileSingleUpLoadFiles_upLoad_hashMap.add(hashMapTemp);
                    }

                }

//                LogUtils.d(ConstantSign.LOGCAT_NOMAL, "执行了--addLocalFileStartUpload---addLocalFileStartUpload---addLocalFileStartUpload");
                mplimageListInEvaluate.addLocalFileStartUpload(result);

                //加载完毕添加
                method_test_upLoadHashMap();

            }
        }


    }

    //为了测试：删除了图片之后，记录上传的string串和后台比较的内容
    private void method_test_edit_update_hashMap() {
        //startTime 为了标识是哪个对象的图片;
        for (HashMap<String, Object> hashMapItem : fileSingleUpLoadFiles_upLoad_hashMap) {
            LogUtils.json(ConstantSign.LOGCAT_NOMAL + "【编辑】之后，也就是【删除】之后->", hashMapItem);
        }
    }

    private void method_test_upLoadHashMap() {
        //startTime 为了标识是哪个对象的图片;
        for (HashMap<String, Object> hashMapItem : fileSingleUpLoadFiles_upLoad_hashMap) {
            LogUtils.json(ConstantSign.LOGCAT_NOMAL + "上传图片集合为->", hashMapItem);
        }
    }

    /**
     * 【上门评估】提交；更新车辆评估
     */
    private void method_gainAddSubmitInfo_upLoad_updateEstimate() {

//        {
//                "shopInfoId": 1495, //店铺Id
//                "customerName": "李梦", //姓名
//                "customerPhone": "1586970804", //手机号
//                "carBrandId": 10, //品牌ID
//                "carBrandName": "奥迪", //品牌名称
//                "carSeriesId": 5, //车系ID
//                "carSeriesName": "A6", //车系名称
//                "vehicleName": "奥迪A6普通款", //车辆型号
//                "address": "裕华区塔北路天同街交叉口路南100米", //看车地点
//                "doorTime": "2023-08-03 15:00", //上门时间
//                "estimateType": 3 //评估类型：1在线评估;2预约评估;3上门评估;4到店评估
//        }

        //如下信息可以删除
        MultipartBody.Builder multipartBodyBuilder = new MultipartBody.Builder()//
                .setType(MultipartBody.FORM);//

        //不是做上传，是为了做日志上传用的
        ArrayList<String> addLogList = new ArrayList<>();

        if (fileSingleUpLoadFiles_upLoad_hashMap != null && !fileSingleUpLoadFiles_upLoad_hashMap.isEmpty()) {

            for (HashMap<String, Object> hashMapItem : fileSingleUpLoadFiles_upLoad_hashMap) {

                //本地路径直接取了上传的；
                String imageLocalPath = (String) hashMapItem.get(Parameterkey.file_path_local);

                if (!TextUtils.isEmpty(imageLocalPath)) {

                    File file = new File(imageLocalPath);

                    if (file.isFile()) {
                        multipartBodyBuilder.addFormDataPart(Parameterkey.files, file.getName(), RequestBody.create(file, MediaType.parse(ApiService.MEDIATYPE_IMAGE_JPG)));//
                    }

                    addLogList.add(imageLocalPath);

                } else {

                    LogUtils.d(ConstantSign.LOGCAT_NOMAL + "imageLocalPath--文件路径是空值--");

                }

            }

        } else {
            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "itchen---->添加报修的图片地址 fileSingleUpLoadFiles_upLoad_hashMap 是空的");
        }


        //为了和后台比对的；
        StringBuffer stringBuffer = new StringBuffer();

        if (fileSingleUpLoadFiles_upLoad_hashMap != null && !fileSingleUpLoadFiles_upLoad_hashMap.isEmpty()) {

            for (int indexPosition = 0; indexPosition < fileSingleUpLoadFiles_upLoad_hashMap.size(); indexPosition++) {

                //后台的path目的是为了比对用的；
                HashMap<String, Object> hashMap = fileSingleUpLoadFiles_upLoad_hashMap.get(indexPosition);

                if (hashMap != null) {

                    String imageServerPath = (String) hashMap.get(Parameterkey.file_path_server);

                    //如若不判断，那么我会提交给后台一个“null”
                    if (!TextUtils.isEmpty(imageServerPath)) {
                        stringBuffer.append(imageServerPath);
                        stringBuffer.append(",");//正常加逗号，最后过滤一次删除末尾逗号；
                    }

//                if (indexPosition != fileSingleUpLoadFiles_upLoad_hashMap.size() - 1) {
//                    stringBuffer.append(",");
//                }

                }
            }

            if (stringBuffer != null) {

                //删除最后一个【逗号】
                //String charAt = stringBuffer.deleteCharAt(stringBuffer.length() - 1).toString().trim();
                if (stringBuffer.length() > 1) {
                    receptionImg_upLoad = stringBuffer.deleteCharAt(stringBuffer.length() - 1).toString().trim();
                } else {
                    LogUtils.d(ConstantSign.LOGCAT_NOMAL + "stringBuffer.length()=>" + stringBuffer.length());
                }

                //receptionImg_upLoad = stringBuffer.toString().trim();
                if (!ObjectUtils.isEmpty(receptionImg_upLoad)) {
                    LogUtils.d(ConstantSign.LOGCAT_NOMAL + "receptionImg_upLoad-->" + receptionImg_upLoad);
                }

            }

        }

        //    public enum EvaluteCarEstimateType {
//            ESTIMATE_TYPE_ONLINE("1", "在线评估"),
//            ESTIMATE_TYPE_BOOKING("2", "预约评估"),
//            ESTIMATE_TYPE_ONDOOR("3", "上门评估"),
//            ESTIMATE_TYPE_ONSTORE("4", "到店评估");

        HashMap<String, Object> map = new HashMap<>();
        map.put(Parameterkey.estimateId, extra_evalute_current_item_bean.getEstimateId());//主键档案id
        map.put(Parameterkey.shopInfoId, mSession.getShopInfoId());//店铺id
        map.put(Parameterkey.customerName, customerName_upLoad);//姓名
        map.put(Parameterkey.customerPhone, customerPhone_upLoad);//手机号
        map.put(Parameterkey.brandId, brandId_upLoad);//车辆品牌
        map.put(Parameterkey.seriesId, seriesId_upLoad);//车系ID
        map.put(Parameterkey.carName, carName_upLoad);//车型
        map.put(Parameterkey.releaseDate, releaseDate_upLoad);//出厂日期
        map.put(Parameterkey.mileage, mileage_upLoad);//公里数
        map.put(Parameterkey.carColor, carColor_upLoad);//颜色
        map.put(Parameterkey.accident, accident_upLoad);//事故ID
        map.put(Parameterkey.wade, wade_upLoad);//涉水ID
        map.put(Parameterkey.remark, remark_upLoad);//备注
        map.put(Parameterkey.priceType, priceType_upLoad);// 价格类型：1一口价;2区间价;
        map.put(Parameterkey.minPrice, minPrice_upLoad);//最低价格
        map.put(Parameterkey.maxPrice, maxPrice_upLoad);//最高价格
        map.put(Parameterkey.priceRemark, priceRemark_upLoad);//评估备注
        map.put(Parameterkey.files, files_upLoad);//图片的id
        map.put(Parameterkey.receptionImg, receptionImg_upLoad);//图片的id

        //上门评估 多携带 上门时间+上门地址信息
//        map.put(Parameterkey.doorTime, doorTime_upLoad);//上门时间
//        map.put(Parameterkey.address, address_upLoad);//上门地址
//        map.put(Parameterkey.estimateType, EvaluteCarEstimateType.ESTIMATE_TYPE_ONDOOR.getIndex());//评估类型：1在线评估;2预约评估;3上门评估;4到店评估
        //============================================================================================================
        multipartBodyBuilder.addFormDataPart(Parameterkey.estimateId, extra_evalute_current_item_bean.getEstimateId());//主键档案id
        multipartBodyBuilder.addFormDataPart(Parameterkey.shopInfoId, mSession.getShopInfoId());
        multipartBodyBuilder.addFormDataPart(Parameterkey.customerName, customerName_upLoad);//姓名
        multipartBodyBuilder.addFormDataPart(Parameterkey.customerPhone, customerPhone_upLoad);//手机号
        multipartBodyBuilder.addFormDataPart(Parameterkey.brandId, brandId_upLoad);//车辆品牌
        multipartBodyBuilder.addFormDataPart(Parameterkey.seriesId, seriesId_upLoad);//车系ID
        multipartBodyBuilder.addFormDataPart(Parameterkey.carName, carName_upLoad);//车型
        multipartBodyBuilder.addFormDataPart(Parameterkey.releaseDate, releaseDate_upLoad);//出厂日期
        multipartBodyBuilder.addFormDataPart(Parameterkey.mileage, mileage_upLoad);//公里数
        multipartBodyBuilder.addFormDataPart(Parameterkey.carColor, carColor_upLoad);//颜色

        LogUtils.d(ConstantSign.LOGCAT_NOMAL + "事故--accident_upLoad=>" + accident_upLoad);

        if (!TextUtils.isEmpty(accident_upLoad)) {
            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "accident_upLoad 不是空的");
            multipartBodyBuilder.addFormDataPart(Parameterkey.accident, accident_upLoad);//事故ID
        } else {
            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "accident_upLoad 是空的");
            multipartBodyBuilder.addFormDataPart(Parameterkey.accident, "");//事故ID
        }

        multipartBodyBuilder.addFormDataPart(Parameterkey.wade, wade_upLoad);//涉水ID
        multipartBodyBuilder.addFormDataPart(Parameterkey.remark, remark_upLoad);//备注
        multipartBodyBuilder.addFormDataPart(Parameterkey.priceType, priceType_upLoad);// 价格类型：1一口价;2区间价;
        multipartBodyBuilder.addFormDataPart(Parameterkey.minPrice, minPrice_upLoad);//最低价格
        multipartBodyBuilder.addFormDataPart(Parameterkey.maxPrice, maxPrice_upLoad);//最高价格
        multipartBodyBuilder.addFormDataPart(Parameterkey.priceRemark, priceRemark_upLoad);//评估备注

        if (!TextUtils.isEmpty(receptionImg_upLoad)) {
            //: 2023-08-25 16:00 使用逗号隔开；这里要认真测试，早期并未认真测试
            multipartBodyBuilder.addFormDataPart(Parameterkey.receptionImg, receptionImg_upLoad);//图片的id
        } else {
            multipartBodyBuilder.addFormDataPart(Parameterkey.receptionImg, "");
        }

        //multipartBodyBuilder.addFormDataPart(Parameterkey.files, files_upLoad);//图片的id
        //上门评估 多携带 上门时间+上门地址信息
//        multipartBodyBuilder.addFormDataPart(Parameterkey.doorTime, doorTime_upLoad);//上门时间
//        multipartBodyBuilder.addFormDataPart(Parameterkey.address, address_upLoad);//上门地址
//        multipartBodyBuilder.addFormDataPart(Parameterkey.estimateType, EvaluteCarEstimateType.ESTIMATE_TYPE_ONDOOR.getIndex());//评估类型：1在线评估;2预约评估;3上门评估;4到店评估

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_UPDATEESTIMATE_URL);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.updateEstimate_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(false);//展示给用户的标志
        addLogUpLoadInfo.setHashMapParameter(map);//仅仅有提交参数的能力

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                .updateEstimate(multipartBodyBuilder.build())
                .compose(CarEvaluateAddSubmitActivity.this.bindUntilEvent(ActivityEvent.DESTROY))
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<String>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);

                        //如果上传失败 要提示;人为的提示
                        if (!TextUtils.isEmpty(serverMessage)) {
                            PopTip.show(serverMessage).iconWarning();
                        }

                    }
                })).subscribe(new Consumer<String>() {
                    @Override
                    public void accept(String stringValue) throws Throwable {

                        method_upLoad_addSubmit_success();

                    }
                }, new ErrorConsumer() {

                    @Override
                    protected void error(ApiException apiException) {

                        //retain

                    }
                });

    }


    /**
     * 这种是 普通的【到店评估】也是，也即是员工【直接添加的】没有类别的评估
     */
    //执行上传操作
    private void method_gainAddSubmitInfo_upLoad_ESTIMATE_TYPE_ONSTORE() {

        //如下信息可以删除

//        //姓名信息
//        customerName_upLoad = editViewNameValuate.getText().toString().trim();
//        //手机号信息
//        customerPhone_upLoad = editViewPhoneEvaluate.getText().toString().trim();
//        //喜好的车型，该车车辆的车型
//        carName_upLoad = editViewInputEvaluateCarModel.getText().toString().trim();
//        //公里数
//        mileage_upLoad = editViewCarMileOutSide.getText().toString();
//        //车辆颜色
//        carColor_upLoad = editViewCarInputColor.getText().toString();
//        //备注信息
//        remark_upLoad = editViewContentEvaluateRemark.getText().toString().trim();
//
//        //评估的价格：一口价和区间价
//        if (priceType_upLoad == EvalutePriceType.PRICETYPE_ONE_SINGLE.getIndex()) {
//            minPrice_upLoad = textViewPriceForEvaluate.getText().toString().trim();
//            maxPrice_upLoad = textViewPriceForEvaluate.getText().toString().trim();
//        } else if (priceType_upLoad == EvalutePriceType.PRICETYPE_TWO_RANGE.getIndex()) {
//            minPrice_upLoad = editViewEvaluateMinPrice.getText().toString().trim();
//            maxPrice_upLoad = editViewEvaluateMaxPrice.getText().toString().trim();
//        }
//        //评估的备注信息
//        priceRemark_upLoad = editViewEvaluateBottomRemark.getText().toString().trim();

        MultipartBody.Builder multipartBodyBuilder = new MultipartBody.Builder()//
                .setType(MultipartBody.FORM);//

        //不是做上传，是为了做日志上传用的
        ArrayList<String> addLogList = new ArrayList<>();

        if (fileSingleUpLoadFiles_upLoad_hashMap != null && !fileSingleUpLoadFiles_upLoad_hashMap.isEmpty()) {

            for (HashMap<String, Object> hashMapItem : fileSingleUpLoadFiles_upLoad_hashMap) {

                String imageLocalPath = (String) hashMapItem.get(Parameterkey.file_path_local);

                if (!TextUtils.isEmpty(imageLocalPath)) {

                    File file = new File(imageLocalPath);
                    multipartBodyBuilder.addFormDataPart(Parameterkey.files, file.getName(),//
                            RequestBody.create(file, MediaType.parse(ApiService.MEDIATYPE_IMAGE_JPG)));//


                    addLogList.add(imageLocalPath);
                }
            }

        } else {
            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "itchen---->添加报修的图片地址 fileSingleUpLoadFiles_upLoad_hashMap 是空的");
        }

        HashMap<String, Object> map = new HashMap<>();
        map.put(Parameterkey.shopInfoId, mSession.getShopInfoId());//店铺id
        map.put(Parameterkey.customerName, customerName_upLoad);//姓名
        map.put(Parameterkey.customerPhone, customerPhone_upLoad);//手机号
        map.put(Parameterkey.brandId, brandId_upLoad);//车辆品牌
        map.put(Parameterkey.seriesId, seriesId_upLoad);//车系ID
        map.put(Parameterkey.carName, carName_upLoad);//车型
        map.put(Parameterkey.releaseDate, releaseDate_upLoad);//出厂日期
        map.put(Parameterkey.mileage, mileage_upLoad);//公里数
        map.put(Parameterkey.carColor, carColor_upLoad);//颜色
        map.put(Parameterkey.accident, accident_upLoad);//事故ID
        map.put(Parameterkey.wade, wade_upLoad);//涉水ID
        map.put(Parameterkey.remark, remark_upLoad);//备注
        map.put(Parameterkey.priceType, priceType_upLoad);// 价格类型：1一口价;2区间价;
        map.put(Parameterkey.minPrice, minPrice_upLoad);//最低价格
        map.put(Parameterkey.maxPrice, maxPrice_upLoad);//最高价格
        map.put(Parameterkey.priceRemark, priceRemark_upLoad);//评估备注
        map.put(Parameterkey.files, files_upLoad);//图片的id
        map.put(Parameterkey.receptionImg, receptionImg_upLoad);//如果是正常的【添加】逻辑图片是空的，这个字段也是空的
        //============================================================================================================

        multipartBodyBuilder.addFormDataPart(Parameterkey.shopInfoId, mSession.getShopInfoId());
        multipartBodyBuilder.addFormDataPart(Parameterkey.customerName, customerName_upLoad);//姓名
        multipartBodyBuilder.addFormDataPart(Parameterkey.customerPhone, customerPhone_upLoad);//手机号
        multipartBodyBuilder.addFormDataPart(Parameterkey.brandId, brandId_upLoad);//车辆品牌
        multipartBodyBuilder.addFormDataPart(Parameterkey.seriesId, seriesId_upLoad);//车系ID
        multipartBodyBuilder.addFormDataPart(Parameterkey.carName, carName_upLoad);//车型
        multipartBodyBuilder.addFormDataPart(Parameterkey.releaseDate, releaseDate_upLoad);//出厂日期
        multipartBodyBuilder.addFormDataPart(Parameterkey.mileage, mileage_upLoad);//公里数
        multipartBodyBuilder.addFormDataPart(Parameterkey.carColor, carColor_upLoad);//颜色
        multipartBodyBuilder.addFormDataPart(Parameterkey.accident, accident_upLoad);//事故ID
        multipartBodyBuilder.addFormDataPart(Parameterkey.wade, wade_upLoad);//涉水ID
        multipartBodyBuilder.addFormDataPart(Parameterkey.remark, remark_upLoad);//备注
        multipartBodyBuilder.addFormDataPart(Parameterkey.priceType, priceType_upLoad);// 价格类型：1一口价;2区间价;
        multipartBodyBuilder.addFormDataPart(Parameterkey.minPrice, minPrice_upLoad);//最低价格
        multipartBodyBuilder.addFormDataPart(Parameterkey.maxPrice, maxPrice_upLoad);//最高价格
        multipartBodyBuilder.addFormDataPart(Parameterkey.priceRemark, priceRemark_upLoad);//评估备注

        if (!TextUtils.isEmpty(receptionImg_upLoad)) {
            // : 2023-08-25 16:00 使用逗号隔开；这里要认真测试，早期并未认真测试
            multipartBodyBuilder.addFormDataPart(Parameterkey.receptionImg, receptionImg_upLoad);//图片的id
        } else {
            multipartBodyBuilder.addFormDataPart(Parameterkey.receptionImg, "");
        }
        //multipartBodyBuilder.addFormDataPart(Parameterkey.files, files_upLoad);//图片的id

//        if (addLogList != null && !addLogList.isEmpty()) {
//            for (String path : addLogList) {//图片的路径
//                File file = new File(path);
//                //RequestBody requestBodyImages = RequestBody.create(file,MediaType.parse("multipart/form-data"));
//                //RequestBody requestBodyImages = RequestBody.create(file, MediaType.parse(ApiService.MEDIATYPE_IMAGE_JPG));
//                multipartBodyBuilder.addFormDataPart(Parameterkey.files, file.getName(),//
//                        RequestBody.create(file, MediaType.parse(ApiService.MEDIATYPE_IMAGE_JPG)));//
//            }
//        }

        AddLogUpLoadInfo addLogUpLoadInfo = new AddLogUpLoadInfo();
        addLogUpLoadInfo.setActivity(mActivityInstance);
        addLogUpLoadInfo.setWhat(ConstantApi.WHAT_ADDESTIMATE);//请求数字标识
        addLogUpLoadInfo.setUrlPath(ApiService.addEstimate_url);//url地址
        addLogUpLoadInfo.setRequestMethod(ConstantSign.REQUEST_METHOD_POST);//POST 或者 GET
        addLogUpLoadInfo.setToastToUser(false);//展示给用户的标志
        addLogUpLoadInfo.setHashMapParameter(map);//仅仅有提交参数的能力

        NetworkManager.getInstance().initRetrofitRxJava()
                .create(ApiService.class)
                .addEstimate(multipartBodyBuilder.build())
                .compose(CarEvaluateAddSubmitActivity.this.bindUntilEvent(ActivityEvent.DESTROY))
                .compose(new ResponseTransformer<>(addLogUpLoadInfo, new ApiRequestSubListener<String>() {
                    @Override
                    public void handlerSomeThingNotSuccessDataForItSelf(int what_method, String serverCode, String serverMessage) {
                        super.handlerSomeThingNotSuccessDataForItSelf(what_method, serverCode, serverMessage);

                        //如果上传失败 要提示;人为的提示
                        if (!TextUtils.isEmpty(serverMessage)) {
                            PopTip.show(serverMessage).iconWarning();
                        }

                    }
                })).subscribe(new Consumer<String>() {
                    @Override
                    public void accept(String stringValue) throws Throwable {

                        method_upLoad_addSubmit_success();

                    }
                }, new ErrorConsumer() {

                    @Override
                    protected void error(ApiException apiException) {

                        //retain

                    }
                });

    }

    //添加处理上传成功之后的通用处理；4种类型
    private void method_upLoad_addSubmit_success() {

        //TipDialog.show(StringUtils.getString(R.string.add_submit_success), WaitDialog.TYPE.SUCCESS);

        if (extra_evaluate_detail_is_edit) {
            //如果是【编辑】，先通知 该详情刷新：因为有图片的【删除或者增加】
            EventCarEvaluateDetail eventCarEvaluateDetail = new EventCarEvaluateDetail();
            eventCarEvaluateDetail.setMessage(ExtraValue.EVENTBUS_EVENT_TO_REFRESH_EVALUATE_CAR_DETAIL);
            EventBus.getDefault().post(eventCarEvaluateDetail);
        }

        //通知主页列表刷新
        EventCarEvaluateMain eventCarEvaluateMain = new EventCarEvaluateMain();
        eventCarEvaluateMain.setMessage(ExtraValue.EVENTBUS_EVENT_TO_REFRESH_EVALUATE_CAR_LIST);
        EventBus.getDefault().post(eventCarEvaluateMain);

        //该页面关闭，
        //提示提交成功，然后1秒后关闭界面
        methodSubmitSuccess(CarEvaluateAddSubmitActivity.this, new DoSomeThingListener() {
            @Override
            public void doSomeThing() {
                //关闭该页面
                methodBack();
            }
        });

    }

    private void initConfig() {

        // 拍摄有关设置
        CameraSetting cameraSetting = new CameraSetting();
        // 支持的类型：图片，视频
        cameraSetting.mimeTypeSet(MimeType.ofImage());
        // 相册
        AlbumSetting albumSetting = new AlbumSetting(true);
        albumSetting.mimeTypeSet(MimeType.ofImage());
        albumSetting.showSingleMediaType(true);
        albumSetting.countable(true);
        albumSetting.addFilter(new GifSizeFilter(320, 320, 5 * BaseFilter.K * BaseFilter.K));
        albumSetting.gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size));
        albumSetting.thumbnailScale(0.85f);
        albumSetting.setOnSelectedListener(localFiles -> {
            // 每次选择的事件
//                    LogUtils.d("itchen---onSelected", "onSelected: localFiles.size()=" + localFiles.size());
        });
        albumSetting.originalEnable(true);
        albumSetting.maxOriginalSize(Parameterkey.maxOriginalSize_one);
        albumSetting.setOnCheckedListener(isChecked -> {
            // 是否勾选了原图
//                    LogUtils.d("itchen----isChecked", "onCheck: isChecked=" + isChecked);
        });// 支持的类型：图片，视频
// 仅仅显示一个多媒体类型
// 是否显示多选图片的数字
// 自定义过滤器
// 九宫格大小
// 图片缩放比例
// 开启原图
// 最大原图size,仅当originalEnable为true的时候才有效
// 录音机
//        RecorderSetting recorderSetting = new RecorderSetting();

        // 全局
        mGlobalSetting = MultiMediaSetting.from(CarEvaluateAddSubmitActivity.this)
                .choose(MimeType.ofImage())
                .albumSetting(albumSetting)
                .cameraSetting(cameraSetting)
//                .recorderSetting(recorderSetting)
                // 设置路径和7.0保护路径等等 com.ygxsk.carhome.fileprovider
                .allStrategy(new SaveStrategy(true, ConstantSign.FILE_PROVIDER, ConstantSign.FILE_PROVIDER_AA_TEST))//"AA/test"
                // 如果设置这个，有关图片的优先权比allStrategy高
                .pictureStrategy(new SaveStrategy(true, ConstantSign.FILE_PROVIDER, ConstantSign.FILE_PROVIDER_AA_PICTURE))//AA/picture
                // 如果设置这个，有关音频的优先权比allStrategy高
                //.audioStrategy(new SaveStrategy(true, "com.ygxsk.integrated.fileprovider", "AA/audio"))
                // 如果设置这个，有关视频的优先权比allStrategy高
                .videoStrategy(new SaveStrategy(true, ConstantSign.FILE_PROVIDER, ConstantSign.FILE_PROVIDER_AA_VIDEO))//"AA/video"
                //  .imageEngine(new GlideEngine())  // for glide-V3     // for glide-V4
                .imageEngine(new Glide4Engine());

    }


    @Override
    protected void onDestroy() {
        super.onDestroy();

        if (extra_evalute_current_evaluate_detail_item_bean_outside != null) {
            extra_evalute_current_evaluate_detail_item_bean_outside = null;
        }

        if (extra_evalute_current_item_bean != null) {
            extra_evalute_current_item_bean = null;
        }

        if (extra_evaluate_detail_is_edit) {
            extra_evaluate_detail_is_edit = false;
        }

        if (basePopupView_carBrandLargeCategory != null) {
            basePopupView_carBrandLargeCategory.onDestroy();
            basePopupView_carBrandLargeCategory = null;
        }

        if (basePopupView_carBrandSeriesSmallCategory != null) {
            basePopupView_carBrandSeriesSmallCategory.onDestroy();
            basePopupView_carBrandSeriesSmallCategory = null;
        }

        if (basePopupView_manufacture_time != null) {
            basePopupView_manufacture_time.onDestroy();
            basePopupView_manufacture_time = null;
        }

        if (basePopupView_carProblem != null) {
            basePopupView_carProblem.onDestroy();
            basePopupView_carProblem = null;
        }


        if (basePopupView_carWade != null) {
            basePopupView_carWade.onDestroy();
            basePopupView_carWade = null;
        }

        if (basePopupView_carPriceType != null) {
            basePopupView_carPriceType.onDestroy();
            basePopupView_carPriceType = null;
        }

        if (mGlobalSetting != null) {
            mGlobalSetting.onDestroy();
        }

        if (fileSingleUpLoadFiles_upLoad_hashMap != null && !fileSingleUpLoadFiles_upLoad_hashMap.isEmpty()) {
            fileSingleUpLoadFiles_upLoad_hashMap.clear();
            fileSingleUpLoadFiles_upLoad_hashMap = null;
        }

        if (mGlobalSetting != null) {
            mGlobalSetting.onDestroy();
        }

    }

    @Override
    protected void methodBack() {

        methodBackFinish();

    }

    @Override
    public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
        //
    }

    @Override
    public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {

        if (requestCode == PRC_PHOTO_PICKER) {
            Toast.makeText(this, StringUtils.getString(R.string.imageselectdenied), Toast.LENGTH_SHORT).show();
        } else if (requestCode == PRC_PHOTO_PREVIEW) {
            //Toast.makeText(this, "您拒绝了「图片预览」所需要的相关权限!", Toast.LENGTH_SHORT).show();
            Toast.makeText(this, StringUtils.getString(R.string.image_preview), Toast.LENGTH_SHORT).show();
        }
    }

    @Override
    public void processExtraData() {

        Bundle extras_bundle = this.getIntent().getExtras();

        if (extras_bundle != null) {

            flag_jumpfrom_where_type = extras_bundle.getString(ExtraKey.EXTRA_JUMPFROM_WHERE_TYPE);

            extra_evaluate_detail_is_edit = extras_bundle.getBoolean(ExtraKey.EXTRA_EVALUATE_DETAIL_IS_EDIT);

            //是哪种类型的评估
//            LogUtils.d(ConstantSign.LOGCAT_NOMAL + "flag_jumpfrom_where_type-->" + flag_jumpfrom_where_type);
//            public enum EvaluteCarEstimateType {
//                ESTIMATE_TYPE_ONLINE("1", "在线评估"),
//                ESTIMATE_TYPE_BOOKING("2", "预约评估"),
//                ESTIMATE_TYPE_ONDOOR("3", "上门评估"),
//                ESTIMATE_TYPE_ONSTORE("4", "到店评估");

            extra_evalute_current_item_bean = extras_bundle.getParcelable(ExtraKey.EXTRA_EVALUTE_CURRENT_ITEM_BEAN);

            LogUtils.json(ConstantSign.LOGCAT_NOMAL + "从列表--车辆评估携带的实体-->", extra_evalute_current_item_bean);

            //从详情携带过去的，编辑
            extra_evalute_current_evaluate_detail_item_bean_outside = extras_bundle.getParcelable(ExtraKey.EXTRA_EVALUTE_CURRENT_EVALUATE_DETAIL_ITEM_BEAN_OUTSIDE);
            //从详情携带车辆品牌
            if (extra_evalute_current_evaluate_detail_item_bean_outside != null) {

                //车辆品牌
                brandId_upLoad = extra_evalute_current_evaluate_detail_item_bean_outside.getBrandId();

                //车辆车系
                seriesId_upLoad = extra_evalute_current_evaluate_detail_item_bean_outside.getSeriesId();

                //车辆事故id
                accident_upLoad = extra_evalute_current_evaluate_detail_item_bean_outside.getAccident();

                //车辆涉水id
                wade_upLoad = extra_evalute_current_evaluate_detail_item_bean_outside.getWade();

                //价格类型 一口价 还是 区间价
                priceType_upLoad = extra_evalute_current_evaluate_detail_item_bean_outside.getPriceType();

            }

        }
    }
}